Class: BqFactory::Attribute
- Inherits:
-
Object
- Object
- BqFactory::Attribute
- Defined in:
- lib/bq_factory/attribute.rb
Constant Summary collapse
- PERMIT_TYPES =
%i(STRING INTEGER FLOAT TIMESTAMP BOOLEAN RECORD).freeze
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(name, type) ⇒ Attribute
constructor
A new instance of Attribute.
- #to_sql ⇒ Object
Constructor Details
#initialize(name, type) ⇒ Attribute
Returns a new instance of Attribute.
8 9 10 11 12 13 |
# File 'lib/bq_factory/attribute.rb', line 8 def initialize(name, type) type = type.to_sym raise ArgumentError.new, "#{type} is not implemented" unless PERMIT_TYPES.include?(type) @name = name @type = type end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/bq_factory/attribute.rb', line 6 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/bq_factory/attribute.rb', line 6 def type @type end |
#value ⇒ Object
Returns the value of attribute value.
5 6 7 |
# File 'lib/bq_factory/attribute.rb', line 5 def value @value end |
Instance Method Details
#to_sql ⇒ Object
15 16 17 |
# File 'lib/bq_factory/attribute.rb', line 15 def to_sql "#{cast_to_sql(value)} AS #{name}" end |