Class: LibBin::DataRange
- Inherits:
-
Object
- Object
- LibBin::DataRange
- Defined in:
- lib/libbin/data_types.rb,
ext/libbin/libbin_c.c
Overview
Classs that can be used to get the shape of a Structure or of a Structure::Scalar.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#range ⇒ Object
readonly
Returns the value of attribute range.
Instance Method Summary collapse
-
#first ⇒ Integer
Return the beginning of the shape.
-
#initialize(*args) ⇒ DataRange
constructor
A new instance of DataRange.
-
#last ⇒ Integer
Return the end of the shape.
-
#size ⇒ Integer
Return the size of the shape.
Constructor Details
#initialize(min, max) ⇒ DataShape #initialize(members) ⇒ DataShape
Returns a new instance of DataRange.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/libbin/data_types.rb', line 32 def initialize(*args) if args.length == 2 @range = Range::new(args[0], args[1]) else if args[0].kind_of?(Hash) @range = args[0].values.compact.collect(&:range).reduce(:+) else @range = args[0].compact.collect(&:range).reduce(:+) end end end |
Instance Attribute Details
#range ⇒ Object (readonly)
Returns the value of attribute range.
20 21 22 |
# File 'lib/libbin/data_types.rb', line 20 def range @range end |
Instance Method Details
#first ⇒ Integer
Return the beginning of the shape
46 47 48 |
# File 'lib/libbin/data_types.rb', line 46 def first @range.first end |
#last ⇒ Integer
Return the end of the shape
52 53 54 |
# File 'lib/libbin/data_types.rb', line 52 def last @range.last end |
#size ⇒ Integer
Return the size of the shape
58 59 60 |
# File 'lib/libbin/data_types.rb', line 58 def size @range.size end |