Class: FellowshipOne::StatusList
- Inherits:
-
Object
- Object
- FellowshipOne::StatusList
- Includes:
- Enumerable
- Defined in:
- lib/api/status_list.rb
Instance Attribute Summary collapse
-
#additional_pages ⇒ Object
readonly
Returns the value of attribute additional_pages.
-
#count ⇒ Object
(also: #size)
readonly
Returns the value of attribute count.
-
#page_number ⇒ Object
readonly
Returns the value of attribute page_number.
-
#total_records ⇒ Object
readonly
Returns the value of attribute total_records.
Instance Method Summary collapse
-
#[](index) ⇒ Object
Get the specified status.
-
#each(&block) ⇒ Object
This method is needed for Enumerable.
-
#empty? ⇒ Boolean
Checks if the list is empty.
-
#initialize(options = {}) ⇒ StatusList
constructor
Constructor.
Constructor Details
#initialize(options = {}) ⇒ StatusList
Constructor.
Options: :reader - (optional) The Reader to use to load the data.
16 17 18 19 20 21 22 23 |
# File 'lib/api/status_list.rb', line 16 def initialize( = {}) reader = [:reader] || FellowshipOne::StatusListReader.new() @json_data = reader.load_feed @count = @json_data['statuses']['status'].size.to_i @page_number = 1 @total_records = @count @additional_pages = 0 end |
Instance Attribute Details
#additional_pages ⇒ Object (readonly)
Returns the value of attribute additional_pages.
7 8 9 |
# File 'lib/api/status_list.rb', line 7 def additional_pages @additional_pages end |
#count ⇒ Object (readonly) Also known as: size
Returns the value of attribute count.
7 8 9 |
# File 'lib/api/status_list.rb', line 7 def count @count end |
#page_number ⇒ Object (readonly)
Returns the value of attribute page_number.
7 8 9 |
# File 'lib/api/status_list.rb', line 7 def page_number @page_number end |
#total_records ⇒ Object (readonly)
Returns the value of attribute total_records.
7 8 9 |
# File 'lib/api/status_list.rb', line 7 def total_records @total_records end |
Instance Method Details
#[](index) ⇒ Object
Get the specified status.
30 31 32 |
# File 'lib/api/status_list.rb', line 30 def [](index) Status.new( @json_data['statuses']['status'][index] ) if @json_data['statuses']['status'][index] end |
#each(&block) ⇒ Object
This method is needed for Enumerable.
36 37 38 |
# File 'lib/api/status_list.rb', line 36 def each &block @json_data['statuses']['status'].each{ |status| yield( Status.new(status) )} end |
#empty? ⇒ Boolean
Checks if the list is empty.
47 48 49 |
# File 'lib/api/status_list.rb', line 47 def empty? self.count == 0 ? true : false end |