Class: Virtus::Attribute::Float

Inherits:
Numeric show all
Defined in:
lib/virtus/attribute/float.rb

Overview

Float

Examples:

class ExchangeRate
  include Virtus

  attribute :dollar, Float
end

ExchangeRate.new(:dollar => 2.69)

# typecasting from a string
ExchangeRate.new(:dollar => '2.69')

# typecasting from an integer
ExchangeRate.new(:dollar => 2)

# typecasting from an object which implements #to_f
ExchangeRate.new(:dollar => BigDecimal.new('2.69')

Constant Summary

Constants included from TypeLookup

TypeLookup::TYPE_FORMAT

Instance Attribute Summary

Attributes inherited from Virtus::Attribute

#coercion_method, #default, #name, #options

Method Summary

Methods inherited from Virtus::Attribute

build, #coerce, #define_accessor_methods, #define_reader_method, #define_writer_method, determine_type, #get, #get!, #initialize, #inspect, merge_options, #public_reader?, #public_writer?, #set, #set!, #value_coerced?

Methods included from DescendantsTracker

#add_descendant, #descendants

Methods included from TypeLookup

#determine_type, extended, #primitive

Methods included from Options

#accept_options, #accepted_options, #options

Constructor Details

This class inherits a constructor from Virtus::Attribute