Class: ItemIterator
- Inherits:
-
Object
- Object
- ItemIterator
- Defined in:
- lib/gorse.rb
Instance Attribute Summary collapse
-
#cursor ⇒ Object
readonly
Returns the value of attribute cursor.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(cursor, items) ⇒ ItemIterator
constructor
A new instance of ItemIterator.
Constructor Details
#initialize(cursor, items) ⇒ ItemIterator
Returns a new instance of ItemIterator.
166 167 168 169 |
# File 'lib/gorse.rb', line 166 def initialize(cursor, items) @cursor = cursor @items = items end |
Instance Attribute Details
#cursor ⇒ Object (readonly)
Returns the value of attribute cursor.
186 187 188 |
# File 'lib/gorse.rb', line 186 def cursor @cursor end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
186 187 188 |
# File 'lib/gorse.rb', line 186 def items @items end |
Class Method Details
.from_json(string) ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/gorse.rb', line 171 def self.from_json(string) h = JSON.load string items = (h['Items'] || []).map do |it| Item.new( item_id: it['ItemId'], is_hidden: it['IsHidden'], labels: it['Labels'], categories: it['Categories'], timestamp: it['Timestamp'], comment: it['Comment'] ) end ItemIterator.new(h['Cursor'], items) end |