Class: ML_ruby::ML_float

Inherits:
ML_string show all
Defined in:
lib/ml-ruby/ml_data_types.rb

Instance Method Summary collapse

Methods inherited from ML_string

#inspect

Methods inherited from ML_list

#==, decode, #encode, #size

Constructor Details

#initialize(payload) ⇒ ML_float

Returns a new instance of ML_float.



105
106
107
108
109
110
111
112
113
114
115
# File 'lib/ml-ruby/ml_data_types.rb', line 105

def initialize payload
  #    puts payload.inspect
  unless payload.is_a? Array
    if (payload*100).to_i % 10 == 0
      payload= payload.to_s + "0" 
    else
      payload= payload.to_s.gsub(/\.0/,'.')
    end
  end
  super payload
end

Instance Method Details

#payloadObject



116
117
118
# File 'lib/ml-ruby/ml_data_types.rb', line 116

def payload
  @payload.map {|c|c.payload}.join.gsub(/\.(\d)$/,'.0\1').to_f
end