Class: DubbletrackRemote::Reader::Base
- Inherits:
-
Object
- Object
- DubbletrackRemote::Reader::Base
- Defined in:
- lib/dubbletrack_remote/reader/base.rb
Instance Attribute Summary collapse
-
#use_database ⇒ Object
readonly
Returns the value of attribute use_database.
Instance Method Summary collapse
Instance Attribute Details
#use_database ⇒ Object (readonly)
Returns the value of attribute use_database.
29 30 31 |
# File 'lib/dubbletrack_remote/reader/base.rb', line 29 def use_database @use_database end |
Instance Method Details
#ingest ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/dubbletrack_remote/reader/base.rb', line 43 def ingest items.select { |s| s.changed? || s.new_record? }.each do |item| puts item.to_json item.save end items end |
#items ⇒ Object
31 32 33 |
# File 'lib/dubbletrack_remote/reader/base.rb', line 31 def items @items ||= read_items.sort_by(&:played_at) end |
#read_items ⇒ Object
52 53 54 |
# File 'lib/dubbletrack_remote/reader/base.rb', line 52 def read_items raise "must implement in subclass" end |
#tracks ⇒ Object
35 36 37 |
# File 'lib/dubbletrack_remote/reader/base.rb', line 35 def tracks items.select { |i| i.item_type == DubbletrackRemote::Item::TRACK } end |
#traffic ⇒ Object
39 40 41 |
# File 'lib/dubbletrack_remote/reader/base.rb', line 39 def traffic items.select { |i| i.item_type == DubbletrackRemote::Item::TRAFFIC } end |