Module: Card::Set::Abstract::Pointer

Extended by:
Card::Set
Defined in:
tmpsets/set/mod005-pointer/abstract/01_pointer.rb,
tmpsets/set/mod005-pointer/abstract/01_pointer/edit.rb

Defined Under Namespace

Modules: Edit

Constant Summary

Constants included from Format

Format::TEMPLATE_DIR

Constants included from Event::DelayedEvent

Event::DelayedEvent::DELAY_STAGES

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

Methods included from Card::Set::AdvancedApi

#attachment, #ensure_set, #stage_method

Methods included from Format

#all_set_format_mod!, #define_on_format, #format, #register_set_format, #view

Methods included from Inheritance

#include_set, #include_set_formats

Methods included from Basket

#abstract_basket, #add_to_basket, #basket

Methods included from Trait

#card_accessor, #card_reader, #card_writer

Methods included from Event

#event

Instance Method Details

#diff_argsObject



130
131
132
# File 'tmpsets/set/mod005-pointer/abstract/01_pointer.rb', line 130

def diff_args
  { format: :pointer }
end

#fetch_or_initialize_item_cards(args) ⇒ Object



151
152
153
154
155
156
157
# File 'tmpsets/set/mod005-pointer/abstract/01_pointer.rb', line 151

def fetch_or_initialize_item_cards args
  itype = args[:type] || item_type
  new_args = itype ? { type: itype } : {}
  item_names(args).map do |name|
    Card.fetch name, new: new_args
  end
end

#item_cards(args = {}) ⇒ Object



134
135
136
137
138
139
140
141
142
143
# File 'tmpsets/set/mod005-pointer/abstract/01_pointer.rb', line 134

def item_cards args={}
  if args[:complete]
    query = args.reverse_merge referred_to_by: name
    Card::Query.run query
  elsif args[:known_only]
    known_item_cards args
  else
    fetch_or_initialize_item_cards args
  end
end

#item_ids(args = {}) ⇒ Object



172
173
174
175
176
# File 'tmpsets/set/mod005-pointer/abstract/01_pointer.rb', line 172

def item_ids args={}
  item_names(args).map do |name|
    Card.fetch_id name
  end.compact
end

#item_names(args = {}) ⇒ Object



159
160
161
162
163
164
165
166
167
168
169
170
# File 'tmpsets/set/mod005-pointer/abstract/01_pointer.rb', line 159

def item_names args={}
  context = args[:context] || cardname
  content = args[:content] || raw_content
  content.to_s.split(/\n+/).map do |line|
    item_name = line.gsub(/\[\[|\]\]/, "").strip
    if context == :raw
      item_name
    else
      item_name.to_name.to_absolute context
    end
  end
end

#item_typeObject



178
179
180
181
182
183
184
185
# File 'tmpsets/set/mod005-pointer/abstract/01_pointer.rb', line 178

def item_type
  opt = options_rule_card
  if !opt || opt == self # fixme, need better recursion prevention
    nil
  else
    opt.item_type
  end
end

#known_item_cards(args = {}) ⇒ Object



145
146
147
148
149
# File 'tmpsets/set/mod005-pointer/abstract/01_pointer.rb', line 145

def known_item_cards args={}
  item_names(args).map do |name|
    Card.fetch name
  end.compact
end

#options_rule_cardObject



187
188
189
# File 'tmpsets/set/mod005-pointer/abstract/01_pointer.rb', line 187

def options_rule_card
  rule_card :options
end