Class: GroongaDelta::Mapping::GroongaColumn
- Inherits:
-
Object
- Object
- GroongaDelta::Mapping::GroongaColumn
- Defined in:
- lib/groonga-delta/mapping.rb
Instance Attribute Summary collapse
-
#expression ⇒ Object
readonly
Returns the value of attribute expression.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#restriction ⇒ Object
readonly
Returns the value of attribute restriction.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #arrow_type ⇒ Object
- #generate_value(source_record) ⇒ Object
-
#initialize(name, template, expression, type, restriction) ⇒ GroongaColumn
constructor
A new instance of GroongaColumn.
Constructor Details
#initialize(name, template, expression, type, restriction) ⇒ GroongaColumn
Returns a new instance of GroongaColumn.
179 180 181 182 183 184 185 |
# File 'lib/groonga-delta/mapping.rb', line 179 def initialize(name, template, expression, type, restriction) @name = name @template = template @expression = expression @type = type @restriction = restriction end |
Instance Attribute Details
#expression ⇒ Object (readonly)
Returns the value of attribute expression.
176 177 178 |
# File 'lib/groonga-delta/mapping.rb', line 176 def expression @expression end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
174 175 176 |
# File 'lib/groonga-delta/mapping.rb', line 174 def name @name end |
#restriction ⇒ Object (readonly)
Returns the value of attribute restriction.
178 179 180 |
# File 'lib/groonga-delta/mapping.rb', line 178 def restriction @restriction end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
175 176 177 |
# File 'lib/groonga-delta/mapping.rb', line 175 def template @template end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
177 178 179 |
# File 'lib/groonga-delta/mapping.rb', line 177 def type @type end |
Instance Method Details
#arrow_type ⇒ Object
197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/groonga-delta/mapping.rb', line 197 def arrow_type case @type when nil, "ShortText", "Text", "LongText" :string when "Bool" :boolean when "Time" Arrow::TimestampDataType.new(:nano) else @type end end |
#generate_value(source_record) ⇒ Object
187 188 189 190 191 192 193 194 195 |
# File 'lib/groonga-delta/mapping.rb', line 187 def generate_value(source_record) if @template value = cast(@template % source_record) else evaluator = ExpressionEvaluator.new(source_record) value = evaluator.evaluate(@expression) end normalize_value(value) end |