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:



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

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)


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

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

#first_id(args = {}) ⇒ Integer

Parameters:

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

    see #item_names

Returns:

  • (Integer)


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

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

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

Parameters:

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

    see #item_names

Returns:



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

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

#include_item?(item) ⇒ Boolean

Returns:

  • (Boolean)


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

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



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

def item_cards args={}
  standard_item_cards args
end

#item_count(args = {}) ⇒ Object

MISC



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

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)



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

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



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

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
28
29
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item.rb', line 22

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

#item_strings(args = {}) ⇒ Array

Returns of String objects.

Parameters:

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

    see #item_names

Returns:

  • (Array)

    of String objects



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

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



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

def item_type_card
  item_type_id&.card
end

#item_type_idObject

typically override EITHER #item_type_id OR #item_type_name



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

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

#item_type_nameObject



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

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



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

def item_value item_name
  item_name
end