Module: Card::Set::All::Item::Format

Extended by:
Card::Set::AbstractFormat
Defined in:
platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb

Instance Method Summary collapse

Instance Method Details

#default_item_viewObject



146
147
148
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb', line 146

def default_item_view
  :name
end

#determine_item_view_options_type(options) ⇒ Object



158
159
160
161
162
163
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb', line 158

def determine_item_view_options_type options
  return if options[:type]

  type_name = card.item_type_name
  options[:type] = type_name if type_name
end

#implicit_item_viewObject



135
136
137
138
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb', line 135

def implicit_item_view
  view = voo_items_view || default_item_view
  Card::View.normalize view
end


129
130
131
132
133
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb', line 129

def item_links args={}
  card.item_cards(args).map do |item_card|
    nest_item item_card, view: :link
  end
end

#item_view_options(new_options = {}) ⇒ Object



150
151
152
153
154
155
156
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb', line 150

def item_view_options new_options={}
  options = (voo.items || {}).clone
  options = options.merge new_options
  options[:view] ||= implicit_item_view
  determine_item_view_options_type options
  options
end

#listing(listing_cards, item_args = {}) ⇒ Object



165
166
167
168
169
170
171
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb', line 165

def listing listing_cards, item_args={}
  listing_cards.map do |item_card|
    nest_item item_card, item_args do |rendered, item_view|
      wrap_item rendered, item_view
    end
  end
end

#nest_item(cardish, options = {}, &block) ⇒ Object



123
124
125
126
127
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb', line 123

def nest_item cardish, options={}, &block
  options = item_view_options options
  options[:nest_name] = Card::Name[cardish].s
  nest cardish, options, &block
end

#view: countObject



119
120
121
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb', line 119

view :count do
  try :count
end

#voo_items_viewObject



140
141
142
143
144
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb', line 140

def voo_items_view
  return unless voo && (items = voo.items)

  items[:view]
end

#wrap_item(item, _args = {}) ⇒ Object



173
174
175
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb', line 173

def wrap_item item, _args={}
  item # no wrap in base
end