Module: Card::Name::All::Parts
- Included in:
- Card::Name::All
- Defined in:
- card/lib/card/name/all/parts.rb
Overview
Card methods for handling name parts, eg A and B are both parts of A+B
Instance Method Summary collapse
-
#left(*args) ⇒ Object
-
#left_id=(cardish) ⇒ Object
-
#left_or_new(args = {}) ⇒ Object
-
#right(*args) ⇒ Object
-
#right_id=(cardish) ⇒ Object
-
#tag(*args) ⇒ Object
-
#trunk(*args) ⇒ Object
Instance Method Details
#left(*args) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'card/lib/card/name/all/parts.rb', line 6 def left *args case when simple? then nil when superleft then superleft when name_is_changing? && name.to_name.trunk_name == name_before_act.to_name nil # prevent recursion when, eg, renaming A+B to A+B+C else Card.fetch name.left, *args end end |
#left_id=(cardish) ⇒ Object
37 38 39 |
# File 'card/lib/card/name/all/parts.rb', line 37 def left_id= cardish write_card_or_id :left_id, cardish end |
#left_or_new(args = {}) ⇒ Object
17 18 19 |
# File 'card/lib/card/name/all/parts.rb', line 17 def left_or_new args={} left(args) || Card.new(args.merge(name: name.left)) end |
#right(*args) ⇒ Object
21 22 23 |
# File 'card/lib/card/name/all/parts.rb', line 21 def right *args Card.fetch(name.right, *args) unless simple? end |
#right_id=(cardish) ⇒ Object
33 34 35 |
# File 'card/lib/card/name/all/parts.rb', line 33 def right_id= cardish write_card_or_id :right_id, cardish end |
#tag(*args) ⇒ Object
29 30 31 |
# File 'card/lib/card/name/all/parts.rb', line 29 def tag *args simple? ? self : Card.fetch(name.right, *args) end |
#trunk(*args) ⇒ Object
25 26 27 |
# File 'card/lib/card/name/all/parts.rb', line 25 def trunk *args simple? ? self : left(*args) end |