Class: LibBin::DataRange

Inherits:
Object
  • Object
show all
Defined in:
lib/libbin/data_types.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#rangeObject (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

#firstObject



59
60
61
# File 'lib/libbin/data_types.rb', line 59

def first
  @range.first
end

#lastObject



63
64
65
# File 'lib/libbin/data_types.rb', line 63

def last
  @range.last
end

#sizeObject



67
68
69
# File 'lib/libbin/data_types.rb', line 67

def size
  @range.size
end