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.
175 176 177 178 179 180 181 |
# File 'lib/groonga-delta/mapping.rb', line 175 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.
172 173 174 |
# File 'lib/groonga-delta/mapping.rb', line 172 def expression @expression end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
170 171 172 |
# File 'lib/groonga-delta/mapping.rb', line 170 def name @name end |
#restriction ⇒ Object (readonly)
Returns the value of attribute restriction.
174 175 176 |
# File 'lib/groonga-delta/mapping.rb', line 174 def restriction @restriction end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
171 172 173 |
# File 'lib/groonga-delta/mapping.rb', line 171 def template @template end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
173 174 175 |
# File 'lib/groonga-delta/mapping.rb', line 173 def type @type end |
Instance Method Details
#arrow_type ⇒ Object
193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/groonga-delta/mapping.rb', line 193 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
183 184 185 186 187 188 189 190 191 |
# File 'lib/groonga-delta/mapping.rb', line 183 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 |