Module: Card::Format::Nest::Subformat
- Included in:
- Card::Format::Nest
- Defined in:
- lib/card/format/nest/subformat.rb
Instance Method Summary collapse
- #depth ⇒ Object
- #field_subformat(field) ⇒ Object
-
#focal? ⇒ Boolean
meaning the current card is the requested card.
- #main? ⇒ Boolean
- #root ⇒ Object
- #subformat(subcard) ⇒ Object
Instance Method Details
#depth ⇒ Object
14 15 16 |
# File 'lib/card/format/nest/subformat.rb', line 14 def depth @depth ||= parent ? (parent.depth + 1) : 0 end |
#field_subformat(field) ⇒ Object
26 27 28 29 |
# File 'lib/card/format/nest/subformat.rb', line 26 def field_subformat field field = card.cardname.field(field) unless field.is_a?(Card) subformat field end |
#focal? ⇒ Boolean
meaning the current card is the requested card
22 23 24 |
# File 'lib/card/format/nest/subformat.rb', line 22 def focal? # meaning the current card is the requested card depth.zero? end |
#main? ⇒ Boolean
18 19 20 |
# File 'lib/card/format/nest/subformat.rb', line 18 def main? depth.zero? end |
#root ⇒ Object
10 11 12 |
# File 'lib/card/format/nest/subformat.rb', line 10 def root @root ||= parent ? parent.root : self end |