Class: MicrosoftLive::Collector
- Inherits:
-
Object
- Object
- MicrosoftLive::Collector
- Includes:
- HTTParty
- Defined in:
- lib/microsoft-live/collector.rb
Instance Attribute Summary collapse
-
#item_class ⇒ Object
Returns the value of attribute item_class.
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#page_size ⇒ Object
Returns the value of attribute page_size.
-
#path ⇒ Object
Returns the value of attribute path.
-
#result ⇒ Object
Returns the value of attribute result.
-
#simple ⇒ Object
Returns the value of attribute simple.
Instance Method Summary collapse
-
#initialize(simple:, path:, limit:, offset:, page_size: 50, item_class:) ⇒ Collector
constructor
A new instance of Collector.
- #items ⇒ Object
- #next_page ⇒ Object
Constructor Details
#initialize(simple:, path:, limit:, offset:, page_size: 50, item_class:) ⇒ Collector
Returns a new instance of Collector.
8 9 10 11 12 13 14 15 |
# File 'lib/microsoft-live/collector.rb', line 8 def initialize(simple:, path:, limit:, offset:, page_size: 50, item_class:) self.simple = simple self.path = path self.limit = limit self.offset = offset self.page_size = page_size self.item_class = item_class end |
Instance Attribute Details
#item_class ⇒ Object
Returns the value of attribute item_class.
5 6 7 |
# File 'lib/microsoft-live/collector.rb', line 5 def item_class @item_class end |
#limit ⇒ Object
Returns the value of attribute limit.
5 6 7 |
# File 'lib/microsoft-live/collector.rb', line 5 def limit @limit end |
#offset ⇒ Object
Returns the value of attribute offset.
5 6 7 |
# File 'lib/microsoft-live/collector.rb', line 5 def offset @offset end |
#page_size ⇒ Object
Returns the value of attribute page_size.
5 6 7 |
# File 'lib/microsoft-live/collector.rb', line 5 def page_size @page_size end |
#path ⇒ Object
Returns the value of attribute path.
5 6 7 |
# File 'lib/microsoft-live/collector.rb', line 5 def path @path end |
#result ⇒ Object
Returns the value of attribute result.
5 6 7 |
# File 'lib/microsoft-live/collector.rb', line 5 def result @result end |
#simple ⇒ Object
Returns the value of attribute simple.
5 6 7 |
# File 'lib/microsoft-live/collector.rb', line 5 def simple @simple end |
Instance Method Details
#items ⇒ Object
17 18 19 20 21 22 |
# File 'lib/microsoft-live/collector.rb', line 17 def items response = simple.get_collection(url: path, limit: limit, offset: offset) response[:data].map do |item| item_class.new(data: item, simple: simple) end end |
#next_page ⇒ Object
24 25 26 27 |
# File 'lib/microsoft-live/collector.rb', line 24 def next_page self.offset += page_size items end |