Class: Groonga::Command::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/groonga/command/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, pair_arguments, ordered_arguments = []) ⇒ Base

Returns a new instance of Base.



44
45
46
47
48
49
50
# File 'lib/groonga/command/base.rb', line 44

def initialize(name, pair_arguments, ordered_arguments=[])
  @name = name
  @arguments = construct_arguments(pair_arguments, ordered_arguments)
  @original_format = nil
  @original_source = nil
  @path_prefix = "/d/"
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



42
43
44
# File 'lib/groonga/command/base.rb', line 42

def arguments
  @arguments
end

#nameObject (readonly)

Returns the value of attribute name.



42
43
44
# File 'lib/groonga/command/base.rb', line 42

def name
  @name
end

#original_formatObject

Returns the value of attribute original_format.



43
44
45
# File 'lib/groonga/command/base.rb', line 43

def original_format
  @original_format
end

#original_sourceObject

Returns the value of attribute original_source.



43
44
45
# File 'lib/groonga/command/base.rb', line 43

def original_source
  @original_source
end

#path_prefixObject

Returns the value of attribute path_prefix.



43
44
45
# File 'lib/groonga/command/base.rb', line 43

def path_prefix
  @path_prefix
end

Class Method Details

.parameter_namesObject



37
38
39
# File 'lib/groonga/command/base.rb', line 37

def parameter_names
  []
end

Instance Method Details

#==(other) ⇒ Object



65
66
67
68
69
# File 'lib/groonga/command/base.rb', line 65

def ==(other)
  other.is_a?(self.class) and
    @name == other.name and
    @arguments == other.arguments
end

#[](name) ⇒ Object



52
53
54
# File 'lib/groonga/command/base.rb', line 52

def [](name)
  @arguments[normalize_name(name)]
end

#[]=(name, value) ⇒ Object



56
57
58
# File 'lib/groonga/command/base.rb', line 56

def []=(name, value)
  @arguments[normalize_name(name)] = value
end

#command_format?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/groonga/command/base.rb', line 75

def command_format?
  @original_format == :command
end

#key?(name) ⇒ Boolean Also known as: has_key?

Returns:

  • (Boolean)


60
61
62
# File 'lib/groonga/command/base.rb', line 60

def key?(name)
  @arguments.key?(normalize_name(name))
end

#output_typeObject



79
80
81
# File 'lib/groonga/command/base.rb', line 79

def output_type
  (self[:output_type] || :json).to_sym
end

#to_command_formatObject



87
88
89
# File 'lib/groonga/command/base.rb', line 87

def to_command_format
  Format::Command.new(@name, normalized_arguments).command_line
end

#to_uri_formatObject



83
84
85
# File 'lib/groonga/command/base.rb', line 83

def to_uri_format
  Format::URI.new(@path_prefix, @name, normalized_arguments).path
end

#uri_format?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/groonga/command/base.rb', line 71

def uri_format?
  @original_format == :uri
end