Class: DeltacloudVM::Client::Helpers::Property::Range

Inherits:
Property
  • Object
show all
Defined in:
lib/deltacloud_vm/client/helpers/property_helper.rb

Instance Attribute Summary collapse

Attributes inherited from Property

#default, #name, #unit

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Property

#kind

Constructor Details

#initialize(name, unit, first, last, default = nil) ⇒ Range

Returns a new instance of Range.



47
48
49
50
# File 'lib/deltacloud_vm/client/helpers/property_helper.rb', line 47

def initialize(name, unit, first, last, default=nil)
  @first, @last = first, last
  super(name, unit, default)
end

Instance Attribute Details

#firstObject (readonly)

Returns the value of attribute first.



45
46
47
# File 'lib/deltacloud_vm/client/helpers/property_helper.rb', line 45

def first
  @first
end

#lastObject (readonly)

Returns the value of attribute last.



45
46
47
# File 'lib/deltacloud_vm/client/helpers/property_helper.rb', line 45

def last
  @last
end

Class Method Details

.parse(body) ⇒ Object



56
57
58
59
# File 'lib/deltacloud_vm/client/helpers/property_helper.rb', line 56

def self.parse(body)
  base = super
  new(base.name, base.unit, body.at('range')['first'], body.at('range')['last'], base.default)
end

Instance Method Details

#valueObject



52
53
54
# File 'lib/deltacloud_vm/client/helpers/property_helper.rb', line 52

def value
  ::Range.new(@first.to_i, @last.to_i)
end