Class: Hexabat::MultiplePageRange

Inherits:
Range
  • Object
show all
Defined in:
lib/hexabat/page_range.rb

Instance Method Summary collapse

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

#middleObject



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_countObject



74
75
76
# File 'lib/hexabat/page_range.rb', line 74

def middle_page_count
  middle.page_count
end

#multiple_pages?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/hexabat/page_range.rb', line 78

def multiple_pages?
  true
end

#page_countObject



60
61
62
# File 'lib/hexabat/page_range.rb', line 60

def page_count
  last - first + 1
end