class Grn2Drn::SchemaConverter::Column

Public Class Methods

new(column_create_command) click to toggle source
# File lib/grn2drn/schema-converter.rb, line 154
def initialize(column_create_command)
  @command = column_create_command
end

Public Instance Methods

to_droonga_schema() click to toggle source
# File lib/grn2drn/schema-converter.rb, line 158
def to_droonga_schema
  schema = {}
  set_schema_item(schema, "type", type)
  set_schema_item(schema, "valueType", value_type)
  set_schema_item(schema, "vectorOptions", vector_options)
  set_schema_item(schema, "indexOptions", index_options)
  schema
end

Private Instance Methods

index_options() click to toggle source
# File lib/grn2drn/schema-converter.rb, line 196
def index_options
  return nil unless @command.column_index?
  {
    "section"  => @command.with_section?,
    "weight"   => @command.with_weight?,
    "position" => @command.with_position?,
    "sources"  => @command.sources,
  }
end
set_schema_item(schema, key, value) click to toggle source
# File lib/grn2drn/schema-converter.rb, line 168
def set_schema_item(schema, key, value)
  return if value.nil?
  schema[key] = value
end
type() click to toggle source
# File lib/grn2drn/schema-converter.rb, line 173
def type
  if @command.column_scalar?
    "Scalar"
  elsif @command.column_vector?
    "Vector"
  elsif @command.column_index?
    "Index"
  else
    "Scalar"
  end
end
value_type() click to toggle source
# File lib/grn2drn/schema-converter.rb, line 185
def value_type
  @command.type
end
vector_options() click to toggle source
# File lib/grn2drn/schema-converter.rb, line 189
def vector_options
  return nil unless @command.column_vector?
  {
    "weight" => @command.with_weight?,
  }
end