Class: AWS::Record::Model::Attributes::SortableFloatAttr
- Inherits:
-
FloatAttr
- Object
- Attributes::BaseAttr
- Attributes::FloatAttr
- FloatAttr
- AWS::Record::Model::Attributes::SortableFloatAttr
- Defined in:
- lib/aws/record/model/attributes.rb
Instance Attribute Summary
Attributes inherited from Attributes::BaseAttr
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, options = {}) ⇒ SortableFloatAttr
constructor
A new instance of SortableFloatAttr.
Methods inherited from Attributes::FloatAttr
Methods inherited from Attributes::BaseAttr
allow_set?, #default_value, #deserialize, #persist_as, #serialize, #set?, #type_cast
Constructor Details
#initialize(name, options = {}) ⇒ SortableFloatAttr
Returns a new instance of SortableFloatAttr.
111 112 113 114 115 116 117 |
# File 'lib/aws/record/model/attributes.rb', line 111 def initialize name, = {} range = [:range] raise ArgumentError, "missing required option :range" unless range raise ArgumentError, ":range should be an integer range" unless range.is_a?(Range) and range.first.is_a?(Integer) super(name, ) end |
Class Method Details
.deserialize(string_value, options = {}) ⇒ Object
128 129 130 131 132 133 134 |
# File 'lib/aws/record/model/attributes.rb', line 128 def self.deserialize string_value, = {} expect(String, string_value) do left, right = string_value.split('.') left = SortableIntegerAttr.deserialize(left, ) "#{left}.#{right}".to_f end end |
.serialize(float, options = {}) ⇒ Object
119 120 121 122 123 124 125 126 |
# File 'lib/aws/record/model/attributes.rb', line 119 def self.serialize float, = {} expect(Float, float) do left, right = float.to_s.split('.') left = SortableIntegerAttr.serialize(left.to_i, ) SortableIntegerAttr.check_range(float, ) "#{left}.#{right}" end end |