Module: Card::Set::All::Chunk::Format
- Extended by:
- Card::Set::AbstractFormat
- Defined in:
- platypus/tmp/set/gem-defaults/mod003-content/all/chunk.rb
Instance Method Summary collapse
-
#each_nested_chunk(content: nil, fields: false, uniq: true, virtual: true, &block) ⇒ Object
-
#each_nested_field_chunk(&block) ⇒ Object
-
#edit_field_configs(fields_only = false) ⇒ Array
Of Arrays.
-
#edit_fields ⇒ Object
-
#field_chunks(chunks) ⇒ Object
-
#field_name?(name) ⇒ Boolean
-
#implicit_edit_fields_config(fields_only) ⇒ Object
-
#nest_chunks(content = nil) ⇒ Object
-
#nested_cards(content = nil) ⇒ Object
-
#nested_field_cards(content = nil) ⇒ Object
-
#nested_field_names(content = nil) ⇒ Object
-
#uniq_chunks(chunks) ⇒ Object
Instance Method Details
#each_nested_chunk(content: nil, fields: false, uniq: true, virtual: true, &block) ⇒ Object
82 83 84 85 86 87 |
# File 'platypus/tmp/set/gem-defaults/mod003-content/all/chunk.rb', line 82 def each_nested_chunk content: nil, fields: false, uniq: true, virtual: true, &block return unless block_given? chunks = prepare_nested_chunks content, fields, uniq process_nested_chunks chunks, virtual, &block end |
#each_nested_field_chunk(&block) ⇒ Object
78 79 80 |
# File 'platypus/tmp/set/gem-defaults/mod003-content/all/chunk.rb', line 78 def each_nested_field_chunk &block each_nested_chunk fields: true, &block end |
#edit_field_configs(fields_only = false) ⇒ Array
Returns of Arrays. each is [nest_name, nest_options_hash].
62 63 64 65 66 67 68 |
# File 'platypus/tmp/set/gem-defaults/mod003-content/all/chunk.rb', line 62 def edit_field_configs fields_only=false if edit_fields.present? explicit_edit_fields_config # explicitly configured in voo or code else implicit_edit_fields_config fields_only # inferred from nests end end |
#edit_fields ⇒ Object
45 46 47 |
# File 'platypus/tmp/set/gem-defaults/mod003-content/all/chunk.rb', line 45 def edit_fields voo.edit_structure || [] end |
#field_chunks(chunks) ⇒ Object
99 100 101 |
# File 'platypus/tmp/set/gem-defaults/mod003-content/all/chunk.rb', line 99 def field_chunks chunks chunks.select { |chunk| field_name?(chunk.referee_name) } end |
#field_name?(name) ⇒ Boolean
57 58 59 |
# File 'platypus/tmp/set/gem-defaults/mod003-content/all/chunk.rb', line 57 def field_name? name name.field_of? card.name end |
#implicit_edit_fields_config(fields_only) ⇒ Object
70 71 72 73 74 75 76 |
# File 'platypus/tmp/set/gem-defaults/mod003-content/all/chunk.rb', line 70 def implicit_edit_fields_config fields_only result = [] each_nested_chunk(fields: fields_only) do |chunk| result << [chunk.[:nest_name], chunk.] end result end |
#nest_chunks(content = nil) ⇒ Object
36 37 38 39 |
# File 'platypus/tmp/set/gem-defaults/mod003-content/all/chunk.rb', line 36 def nest_chunks content=nil content ||= _render_raw card.nest_chunks content end |
#nested_cards(content = nil) ⇒ Object
41 42 43 |
# File 'platypus/tmp/set/gem-defaults/mod003-content/all/chunk.rb', line 41 def nested_cards content=nil nest_chunks(content).map(&:referee_card).uniq end |
#nested_field_cards(content = nil) ⇒ Object
53 54 55 |
# File 'platypus/tmp/set/gem-defaults/mod003-content/all/chunk.rb', line 53 def nested_field_cards content=nil nested_cards(content).select { |c| field_name? c.name } end |
#nested_field_names(content = nil) ⇒ Object
49 50 51 |
# File 'platypus/tmp/set/gem-defaults/mod003-content/all/chunk.rb', line 49 def nested_field_names content=nil nest_chunks(content).map(&:referee_name).select { |n| field_name? n } end |
#uniq_chunks(chunks) ⇒ Object
89 90 91 92 93 94 95 96 97 |
# File 'platypus/tmp/set/gem-defaults/mod003-content/all/chunk.rb', line 89 def uniq_chunks chunks processed = ::Set.new [card.key] chunks.select do |chunk| key = chunk.referee_name.key ok = !processed.include?(key) processed << key ok end end |