Sha256: 977f53162909809addce3182d26582a4e31fae80f10665b7f12a8162eb39caf4

Contents?: true

Size: 754 Bytes

Versions: 16

Compression:

Stored size: 754 Bytes

Contents

class Card
  class Format
    module Nest
      module Subformat
        def subformat subcard
          subcard = Card.fetch(subcard, new: {}) unless subcard.is_a?(Card)
          self.class.new subcard, parent: self, format_class: self.class, form: @form
        end

        def root
          @root ||= parent ? parent.root : self
        end

        def depth
          @depth ||= parent ? (parent.depth + 1) : 0
        end

        def main?
          depth.zero?
        end

        def focal? # meaning the current card is the requested card
          depth.zero?
        end

        def field_subformat field
          field = card.name.field(field) unless field.is_a?(Card)
          subformat field
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
card-1.94.1 lib/card/format/nest/subformat.rb
card-1.94.0 lib/card/format/nest/subformat.rb
card-1.93.13 lib/card/format/nest/subformat.rb
card-1.93.12 lib/card/format/nest/subformat.rb
card-1.93.11 lib/card/format/nest/subformat.rb
card-1.93.10 lib/card/format/nest/subformat.rb
card-1.93.9 lib/card/format/nest/subformat.rb
card-1.93.8 lib/card/format/nest/subformat.rb
card-1.93.7 lib/card/format/nest/subformat.rb
card-1.93.6 lib/card/format/nest/subformat.rb
card-1.93.5 lib/card/format/nest/subformat.rb
card-1.93.4 lib/card/format/nest/subformat.rb
card-1.93.3 lib/card/format/nest/subformat.rb
card-1.93.2 lib/card/format/nest/subformat.rb
card-1.93.1 lib/card/format/nest/subformat.rb
card-1.93.0 lib/card/format/nest/subformat.rb