Class: Nbp::Table
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Class Method Summary collapse
Instance Method Summary collapse
- #after(table_id) ⇒ Object
- #before(table_id) ⇒ Object
-
#initialize(type = "a") ⇒ Table
constructor
A new instance of Table.
- #latest ⇒ Object
Constructor Details
#initialize(type = "a") ⇒ Table
Returns a new instance of Table.
8 9 10 |
# File 'lib/nbp/table.rb', line 8 def initialize(type = "a") @index = self.class.index_of(type.downcase) end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
6 7 8 |
# File 'lib/nbp/table.rb', line 6 def index @index end |
Class Method Details
.index ⇒ Object
24 25 26 |
# File 'lib/nbp/table.rb', line 24 def self.index get("/dir.txt").split("\r\n") end |
.index_of(type) ⇒ Object
28 29 30 |
# File 'lib/nbp/table.rb', line 28 def self.index_of(type) index.select { |table_id| table_id.start_with?(type) } end |
.show(table_id) ⇒ Object
32 33 34 |
# File 'lib/nbp/table.rb', line 32 def self.show(table_id) get("/#{table_id}.xml").parsed_response end |
Instance Method Details
#after(table_id) ⇒ Object
16 17 18 |
# File 'lib/nbp/table.rb', line 16 def after(table_id) index.select { |id| index.index(id) > index.index(table_id) } end |
#before(table_id) ⇒ Object
20 21 22 |
# File 'lib/nbp/table.rb', line 20 def before(table_id) index.select { |id| index.index(id) < index.index(table_id) } end |
#latest ⇒ Object
12 13 14 |
# File 'lib/nbp/table.rb', line 12 def latest self.class.show(index.last) end |