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

Extended by:
Card::Set
Defined in:
tmpsets/set/mod003-core/all/item.rb

Overview

Set: All cards (Item)

Defined Under Namespace

Modules: Format, HtmlFormat

Class Method Summary collapse

Instance Method Summary collapse

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

#abstract_set?, #all_set?, #num_set_parts, #shortname, #underscore

Methods included from Card::Set::AdvancedApi

#attachment, #ensure_set, #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 'tmpsets/set/mod003-core/all/item.rb', line 7

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

Instance Method Details

#add_id(id) ⇒ Object



53
54
55
# File 'tmpsets/set/mod003-core/all/item.rb', line 53

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

#add_item(item) ⇒ Object



35
36
37
38
# File 'tmpsets/set/mod003-core/all/item.rb', line 35

def add_item item
  return if include_item? item
  self.content = "#{content}\n#{item}"
end

#drop_id(id) ⇒ Object



57
58
59
# File 'tmpsets/set/mod003-core/all/item.rb', line 57

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

#drop_item(item) ⇒ Object



40
41
42
43
44
# File 'tmpsets/set/mod003-core/all/item.rb', line 40

def drop_item item
  return unless include_item? item
  new_names = item_names.reject { |i| i == item }
  self.content = new_names.empty? ? "" : new_names.join("\n")
end

#include_item?(item) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
33
# File 'tmpsets/set/mod003-core/all/item.rb', line 30

def include_item? item
  key = item.is_a?(Card) ? item.name.key : item.to_name.key
  item_names.map { |name| name.to_name.key }.member? key
end

#insert_id(index, id) ⇒ Object



61
62
63
# File 'tmpsets/set/mod003-core/all/item.rb', line 61

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

#insert_item(index, name) ⇒ Object



46
47
48
49
50
51
# File 'tmpsets/set/mod003-core/all/item.rb', line 46

def insert_item index, name
  new_names = item_names
  new_names.delete name
  new_names.insert index, name
  self.content = new_names.join "\n"
end

#item_cards(_args = {}) ⇒ Object

FIXME: this is inconsistent with item_names



12
13
14
# File 'tmpsets/set/mod003-core/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 'tmpsets/set/mod003-core/all/item.rb', line 26

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

#item_keys(args = {}) ⇒ Object



20
21
22
23
24
# File 'tmpsets/set/mod003-core/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 'tmpsets/set/mod003-core/all/item.rb', line 8

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

#item_typeObject



16
17
18
# File 'tmpsets/set/mod003-core/all/item.rb', line 16

def item_type
  nil
end