You are viewing documentation for version 1 of the AWS SDK for Ruby. Version 2 documentation can be found here.

Class: AWS::Record::Attributes::FloatAttr

Inherits:
BaseAttr
  • Object
show all
Defined in:
lib/aws/record/attributes.rb

Direct Known Subclasses

Model::Attributes::FloatAttr

Instance Attribute Summary

Attributes inherited from BaseAttr

#name, #options

Class Method Summary collapse

Methods inherited from BaseAttr

#default_value, #deserialize, deserialize, #initialize, #persist_as, #serialize, #set?, #type_cast

Constructor Details

This class inherits a constructor from AWS::Record::Attributes::BaseAttr

Class Method Details

.serialize(float, options = {}) ⇒ Object



244
245
246
# File 'lib/aws/record/attributes.rb', line 244

def self.serialize float, options = {}
  expect(Float, float) { float }
end

.type_cast(raw_value, options = {}) ⇒ Object



232
233
234
235
236
237
238
239
240
241
242
# File 'lib/aws/record/attributes.rb', line 232

def self.type_cast raw_value, options = {}
  case raw_value
  when nil   then nil
  when ''    then nil
  when Float then raw_value
  else
    raw_value.respond_to?(:to_f) ?
      raw_value.to_f :
      raw_value.to_s.to_f
  end
end