Class: Hexabat::MultiplePageRange
- Inherits:
-
Range
- Object
- Range
- Hexabat::MultiplePageRange
- Defined in:
- lib/hexabat/page_range.rb
Instance Method Summary collapse
-
#initialize(first, last) ⇒ MultiplePageRange
constructor
A new instance of MultiplePageRange.
- #middle ⇒ Object
- #middle_page_count ⇒ Object
- #multiple_pages? ⇒ Boolean
- #page_count ⇒ Object
Constructor Details
#initialize(first, last) ⇒ MultiplePageRange
Returns a new instance of MultiplePageRange.
56 57 58 |
# File 'lib/hexabat/page_range.rb', line 56 def initialize(first, last) super(first..last) end |
Instance Method Details
#middle ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/hexabat/page_range.rb', line 64 def middle if page_count > 3 MultiplePageRange.new(first.succ, last.pred) elsif page_count == 3 SinglePageRange.new(first.succ) else EmptyPageRange.new end end |
#middle_page_count ⇒ Object
74 75 76 |
# File 'lib/hexabat/page_range.rb', line 74 def middle_page_count middle.page_count end |
#multiple_pages? ⇒ Boolean
78 79 80 |
# File 'lib/hexabat/page_range.rb', line 78 def multiple_pages? true end |
#page_count ⇒ Object
60 61 62 |
# File 'lib/hexabat/page_range.rb', line 60 def page_count last - first + 1 end |