Class: Navagation
- Inherits:
-
Object
- Object
- Navagation
- Defined in:
- lib/nytimes_cli/navagation.rb
Instance Attribute Summary collapse
-
#articles_length ⇒ Object
Returns the value of attribute articles_length.
-
#end_index ⇒ Object
Returns the value of attribute end_index.
-
#start_index ⇒ Object
Returns the value of attribute start_index.
Instance Method Summary collapse
-
#initialize(length) ⇒ Navagation
constructor
A new instance of Navagation.
- #less ⇒ Object
- #more ⇒ Object
Constructor Details
#initialize(length) ⇒ Navagation
5 6 7 8 9 |
# File 'lib/nytimes_cli/navagation.rb', line 5 def initialize(length) @start_index = 0 @end_index = 9 @articles_length = length end |
Instance Attribute Details
#articles_length ⇒ Object
Returns the value of attribute articles_length.
3 4 5 |
# File 'lib/nytimes_cli/navagation.rb', line 3 def articles_length @articles_length end |
#end_index ⇒ Object
Returns the value of attribute end_index.
3 4 5 |
# File 'lib/nytimes_cli/navagation.rb', line 3 def end_index @end_index end |
#start_index ⇒ Object
Returns the value of attribute start_index.
3 4 5 |
# File 'lib/nytimes_cli/navagation.rb', line 3 def start_index @start_index end |
Instance Method Details
#less ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/nytimes_cli/navagation.rb', line 22 def less if @start_index >= 10 @start_index -= 10 @end_index = @start_index + 9 else @start_index = 0 @end_index = 9 end end |
#more ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/nytimes_cli/navagation.rb', line 12 def more if @end_index + 10 < @articles_length @start_index += 10 @end_index += 10 else @start_index = @articles_length - 9 @end_index = @articles_length end end |