Class: Zermelo::Filters::IndexRange
- Inherits:
-
Object
- Object
- Zermelo::Filters::IndexRange
- Defined in:
- lib/zermelo/filters/index_range.rb
Instance Attribute Summary collapse
-
#by_score ⇒ Object
readonly
Returns the value of attribute by_score.
-
#finish ⇒ Object
readonly
Returns the value of attribute finish.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
Instance Method Summary collapse
-
#initialize(start, finish, opts = {}) ⇒ IndexRange
constructor
A new instance of IndexRange.
Constructor Details
#initialize(start, finish, opts = {}) ⇒ IndexRange
Returns a new instance of IndexRange.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/zermelo/filters/index_range.rb', line 7 def initialize(start, finish, opts = {}) value_types = opts[:by_score] ? [Float, Date, Time, DateTime] : [Integer] [start, finish].each do |v| raise "Values must be #{value_types.join('/')}" unless v.nil? || value_types.any? {|vt| v.is_a?(vt)} end if !start.nil? && !finish.nil? && (start > finish) raise "Start of range must be <= finish" end @start = start @finish = finish @by_score = opts[:by_score] end |
Instance Attribute Details
#by_score ⇒ Object (readonly)
Returns the value of attribute by_score.
5 6 7 |
# File 'lib/zermelo/filters/index_range.rb', line 5 def by_score @by_score end |
#finish ⇒ Object (readonly)
Returns the value of attribute finish.
5 6 7 |
# File 'lib/zermelo/filters/index_range.rb', line 5 def finish @finish end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
5 6 7 |
# File 'lib/zermelo/filters/index_range.rb', line 5 def start @start end |