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

Extended by:
Card::Set
Defined in:
card/tmpsets/set/mod006-card-mod-collection/all/item.rb,
card/tmpsets/set/mod005-card-mod-collection/all/item.rb

Overview

Set: All cards (Item)

Defined Under Namespace

Modules: Format, HtmlFormat

Constant Summary

Constants included from Helpers

Helpers::SET_PATTERN_TEST_REGEXP

Constants included from Event::Api

Event::Api::OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Card::Set

reset_modules

Methods included from I18nScope

#mod_name, #scope

Methods included from Loader

#clean_empty_module_from_hash, #clean_empty_modules, #extended, #process_base_modules, #register_set

Methods included from Helpers

#method_missing, #num_set_parts, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscore

Methods included from Card::Set::AdvancedApi

#attachment, #define_set_from_error, #ensure_set, #setting_opts, #stage_method

Methods included from Format

#before, #format, layout_method_name, #view, view_method_name, view_setting_method_name, wrapper_method_name

Methods included from Inheritance

#include_set, #include_set_formats

Methods included from Basket

#abstract_basket, #add_to_basket, #basket, #unshift_basket

Methods included from Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Class Method Details

.source_locationObject



7
# File 'card/tmpsets/set/mod006-card-mod-collection/all/item.rb', line 7

def self.source_location; "/Users/ethan/dev/decko/gem/card-mod-collection/set/all/item.rb"; end

Instance Method Details

#add_id(id) ⇒ Object

I think the following should work as add_item…



69
70
71
# File 'card/tmpsets/set/mod006-card-mod-collection/all/item.rb', line 69

def add_id id
  add_item "~#{id}"
end

#add_item(item) ⇒ Object



43
44
45
46
# File 'card/tmpsets/set/mod006-card-mod-collection/all/item.rb', line 43

def add_item item
  return if include_item? item
  items_to_content(items_strings << item)
end

#drop_id(id) ⇒ Object



73
74
75
# File 'card/tmpsets/set/mod006-card-mod-collection/all/item.rb', line 73

def drop_id id
  drop_item "~#{id}"
end

#drop_item(item) ⇒ Object



48
49
50
51
52
# File 'card/tmpsets/set/mod006-card-mod-collection/all/item.rb', line 48

def drop_item item
  item = Card::Name[item]
  return unless include_item? item
  items_to_content(item_names.reject { |i| i == item })
end

#include_item?(item) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'card/tmpsets/set/mod006-card-mod-collection/all/item.rb', line 39

def include_item? item
  item_names.include? Card::Name[item]
end

#insert_id(index, id) ⇒ Object



77
78
79
# File 'card/tmpsets/set/mod006-card-mod-collection/all/item.rb', line 77

def insert_id index, id
  insert_item index, "~#{id}"
end

#insert_item(index, name) ⇒ Object



54
55
56
57
58
59
# File 'card/tmpsets/set/mod006-card-mod-collection/all/item.rb', line 54

def insert_item index, name
  new_names = item_names
  new_names.delete name
  new_names.insert index, name
  items_to_content new_names
end

#item_cards(_args = {}) ⇒ Object

FIXME: this is inconsistent with item_names



12
13
14
# File 'card/tmpsets/set/mod006-card-mod-collection/all/item.rb', line 12

def item_cards _args={} # FIXME: this is inconsistent with item_names
  [self]
end

#item_count(args = {}) ⇒ Object



26
27
28
# File 'card/tmpsets/set/mod006-card-mod-collection/all/item.rb', line 26

def item_count args={}
  item_names(args).size
end

#item_keys(args = {}) ⇒ Object



20
21
22
23
24
# File 'card/tmpsets/set/mod006-card-mod-collection/all/item.rb', line 20

def item_keys args={}
  item_names(args).map do |item|
    item.to_name.key
  end
end

#item_names(_args = {}) ⇒ Object



8
9
10
# File 'card/tmpsets/set/mod006-card-mod-collection/all/item.rb', line 8

def item_names _args={}
  format._render_raw.split(/[,\n]/)
end

#item_typeObject



16
17
18
# File 'card/tmpsets/set/mod006-card-mod-collection/all/item.rb', line 16

def item_type
  nil
end

#items_to_content(array) ⇒ Object



30
31
32
33
# File 'card/tmpsets/set/mod006-card-mod-collection/all/item.rb', line 30

def items_to_content array
  items = array.map { |i| standardize_item i }.reject(&:blank?)
  self.content = items.to_pointer_content
end

#replace_item(old, new) ⇒ Object



61
62
63
64
65
# File 'card/tmpsets/set/mod006-card-mod-collection/all/item.rb', line 61

def replace_item old, new
  return unless include_item? old
  drop_item old
  add_item new
end

#standardize_item(item) ⇒ Object



35
36
37
# File 'card/tmpsets/set/mod006-card-mod-collection/all/item.rb', line 35

def standardize_item item
  Card::Name[item]
end