Module: Cardio::Mod::Sow::CardSource
- Included in:
- Cardio::Mod::Sow
- Defined in:
- lib/cardio/mod/sow/card_source.rb
Overview
Fetch sow data form cards
Instance Method Summary collapse
- #cards ⇒ Object
- #cards_from_name ⇒ Object
- #field_tag_marks ⇒ Object
- #item_cards ⇒ Object
- #main_cards ⇒ Object
- #new_data_from_cards ⇒ Object
- #require_card(name) ⇒ Object
Instance Method Details
#cards ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/cardio/mod/sow/card_source.rb', line 16 def cards if @name cards_from_name elsif @cql Card.search JSON.parse(@cql).reverse_merge(limit: 0) else raise Card::Error::NotFound, "must specify either name (-n) or CQL (-c)" end end |
#cards_from_name ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/cardio/mod/sow/card_source.rb', line 26 def cards_from_name case @items when :only then item_cards when true then main_cards + item_cards else main_cards end end |
#field_tag_marks ⇒ Object
10 11 12 13 14 |
# File 'lib/cardio/mod/sow/card_source.rb', line 10 def field_tag_marks @field_tag_marks ||= @field_tags.to_s.split(",").map do |mark| mark.strip.cardname.codename_or_string end end |
#item_cards ⇒ Object
34 35 36 |
# File 'lib/cardio/mod/sow/card_source.rb', line 34 def item_cards main_cards.map(&:item_cards).flatten end |
#main_cards ⇒ Object
38 39 40 |
# File 'lib/cardio/mod/sow/card_source.rb', line 38 def main_cards @main_cards ||= @name.split(",").map { |n| require_card n } end |
#new_data_from_cards ⇒ Object
6 7 8 |
# File 'lib/cardio/mod/sow/card_source.rb', line 6 def new_data_from_cards cards.map { |c| c.pod_hash field_tags: field_tag_marks } end |