Class: LibBin::DataRange
- Inherits:
-
Object
- Object
- LibBin::DataRange
- Defined in:
- lib/libbin/data_types.rb
Instance Attribute Summary collapse
-
#range ⇒ Object
readonly
Returns the value of attribute range.
Instance Method Summary collapse
- #first ⇒ Object
-
#initialize(*args) ⇒ DataRange
constructor
A new instance of DataRange.
- #last ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(*args) ⇒ DataRange
Returns a new instance of DataRange.
51 52 53 54 55 56 57 |
# File 'lib/libbin/data_types.rb', line 51 def initialize(*args) if args.length == 2 @range = Range::new(args[0], args[1]) else @range = args[0].values.flatten.compact.collect(&:range).reduce { |memo, obj| memo + obj } end end |
Instance Attribute Details
#range ⇒ Object (readonly)
Returns the value of attribute range.
49 50 51 |
# File 'lib/libbin/data_types.rb', line 49 def range @range end |
Instance Method Details
#first ⇒ Object
59 60 61 |
# File 'lib/libbin/data_types.rb', line 59 def first @range.first end |
#last ⇒ Object
63 64 65 |
# File 'lib/libbin/data_types.rb', line 63 def last @range.last end |
#size ⇒ Object
67 68 69 |
# File 'lib/libbin/data_types.rb', line 67 def size @range.size end |