Class: Fields::Number

Inherits:
Field
  • Object
show all
Defined in:
app/models/iron/fields/number.rb

Instance Method Summary collapse

Instance Method Details

#content_value=(value) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'app/models/iron/fields/number.rb', line 5

def content_value=(value)
  @content_errors = nil

  if value.nil? || value.is_a?(Numeric) || numeric_string?(value)
    self.value_float = value
  else
    add_content_error("must be a number")
  end
end

#export_valueObject



21
22
23
# File 'app/models/iron/fields/number.rb', line 21

def export_value
  { type: "number", value: value_float }
end

#filled?Boolean

Returns:



15
# File 'app/models/iron/fields/number.rb', line 15

def filled? = !value_float.nil?

#valueObject



17
18
19
# File 'app/models/iron/fields/number.rb', line 17

def value
  value_float
end