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

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

Overview

ITEM LISTS

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

Methods included from I18nScope

#mod_name, #scope

Methods included from Registrar

#extended, #finalize_load, #process_base_modules, #register_set

Methods included from Helpers

#format_module, #format_modules, #method_missing, #modules, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscored_name

Methods included from Card::Set::AdvancedApi

#assign_type, #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 Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Class Method Details

.source_locationObject



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

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

Instance Method Details

#first_card(args = {}) ⇒ Card

Parameters:

  • args (Hash) (defaults to: {})

    see #item_names

Returns:



68
69
70
71
72
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb', line 68

def first_card args={}
  return unless (name = first_name)

  fetch_item_card name, args
end

#first_code(args = {}) ⇒ Symbol

Parameters:

  • args (Hash) (defaults to: {})

    see #item_names

Returns:

  • (Symbol)


76
77
78
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb', line 76

def first_code args={}
  first_card(args)&.codename
end

#first_id(args = {}) ⇒ Integer

Parameters:

  • args (Hash) (defaults to: {})

    see #item_names

Returns:

  • (Integer)


82
83
84
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb', line 82

def first_id args={}
  first_name(args)&.card_id
end

#first_name(args = {}) ⇒ Card::Name

Parameters:

  • args (Hash) (defaults to: {})

    see #item_names

Returns:



62
63
64
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb', line 62

def first_name args={}
  item_names(args).first
end

#include_item?(item) ⇒ Boolean

Returns:

  • (Boolean)


107
108
109
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb', line 107

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

#item_cards(args = {}) ⇒ Array

Returns list of cards.

Parameters:

  • args (Hash) (defaults to: {})

    see #item_names

Returns:

  • (Array)

    list of cards



31
32
33
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb', line 31

def item_cards args={}
  standard_item_cards args
end

#item_count(args = {}) ⇒ Object

MISC



103
104
105
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb', line 103

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

#item_ids(args = {}) ⇒ Array

Returns list of integers (card ids of items).

Parameters:

  • args (Hash) (defaults to: {})

    see #item_names

Returns:

  • (Array)

    list of integers (card ids of items)



37
38
39
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb', line 37

def item_ids args={}
  item_names(args).map(&:card_id).compact
end

#item_keys(args = {}) ⇒ Array

Returns of String objects.

Parameters:

  • args (Hash) (defaults to: {})

    see #item_names

Returns:

  • (Array)

    of String objects



43
44
45
46
47
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb', line 43

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

#item_names(args = {}) ⇒ Array

Returns list of Card::Name objects.

Parameters:

  • args (Hash) (defaults to: {})

Options Hash (args):

  • :content (String)

    override card content

  • :context (String, Card::Name, Symbol)

    name in whose context relative items will be interpreted. For example. +A in context of B is interpreted as B+A context defaults to pointer card’s name. If value is :raw, then name is not contextualized

  • :limit (String, Integer)

    max number of cards to return

  • :offset (String, Integer)

    begin after the offset-th item

Returns:

  • (Array)

    list of Card::Name objects



22
23
24
25
26
27
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb', line 22

def item_names args={}
  context = args[:context]
  item_strings(args).map do |item|
    clean_item_name item, context
  end.compact
end

#item_strings(args = {}) ⇒ Array

Returns of String objects.

Parameters:

  • args (Hash) (defaults to: {})

    see #item_names

Returns:

  • (Array)

    of String objects



51
52
53
54
55
56
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb', line 51

def item_strings args={}
  items = raw_item_strings(args[:content] || content)
  return items unless args.present?

  filtered_items items, limit: args[:limit], offset: args[:offset]
end

#item_type_cardObject



97
98
99
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb', line 97

def item_type_card
  item_type_id&.card
end

#item_type_idObject

typically override EITHER #item_type_id OR #item_type_name



89
90
91
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb', line 89

def item_type_id
  @item_type_id ||= no_item_type_recursion { item_type_name&.card_id }
end

#item_type_nameObject



93
94
95
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb', line 93

def item_type_name
  @item_type_name ||= no_item_type_recursion { item_type_id&.cardname }
end

#item_value(item_name) ⇒ Object

for override, eg by json



112
113
114
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb', line 112

def item_value item_name
  item_name
end