Class: BB::Converter::Value

Inherits:
Object
  • Object
show all
Defined in:
lib/b_b/converter/value.rb

Constant Summary collapse

TEMPLATE =
{
  array:     "(%s)",
  date:      "DATE('%Y-%m-%d')",
  null:      "NULL",
  range:     "%s AND %s",
  regexp:    "r'%s'",
  string:    "'%s'",
  subquery:  "(%s)",
  time:      "TIMESTAMP('%Y-%m-%d %H:%M:%S')",
  timestamp: "TIMESTAMP('%Y-%m-%d')"
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, options = {}) ⇒ Value

Returns a new instance of Value.



18
19
20
21
22
# File 'lib/b_b/converter/value.rb', line 18

def initialize(value, options = {})
  @value   = value
  @options = options
  @type    = format_type
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



16
17
18
# File 'lib/b_b/converter/value.rb', line 16

def options
  @options
end

#typeObject (readonly)

Returns the value of attribute type.



16
17
18
# File 'lib/b_b/converter/value.rb', line 16

def type
  @type
end

#valueObject (readonly)

Returns the value of attribute value.



16
17
18
# File 'lib/b_b/converter/value.rb', line 16

def value
  @value
end

Class Method Details

.convert(value, options = {}) ⇒ Object



93
94
95
# File 'lib/b_b/converter/value.rb', line 93

def convert(value, options = {})
  new(value, options).convert
end

Instance Method Details

#convertObject



24
25
26
# File 'lib/b_b/converter/value.rb', line 24

def convert
  send("to_#{type}")
end