Class: Value

Inherits:
Object show all
Defined in:
lib/basic/basic.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(v = 0) ⇒ Value

Returns a new instance of Value


192
193
194
# File 'lib/basic/basic.rb', line 192

def initialize v = 0
	set v
end

Instance Attribute Details

#valueObject

Returns the value of attribute value


190
191
192
# File 'lib/basic/basic.rb', line 190

def value
  @value
end

Instance Method Details

#set(x) ⇒ Object


196
197
198
199
# File 'lib/basic/basic.rb', line 196

def set x
	x.assert_type Numeric
	@value = Float.new x
end

#to_fObject


205
206
207
# File 'lib/basic/basic.rb', line 205

def to_f
	@value
end

#to_iObject


201
202
203
# File 'lib/basic/basic.rb', line 201

def to_i
	@value.to_i
end