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(command_name, pair_arguments, ordered_arguments = []) ⇒ Base



56
57
58
59
60
61
62
# File 'lib/groonga/command/base.rb', line 56

def initialize(command_name, pair_arguments, ordered_arguments=[])
  @command_name = command_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.



54
55
56
# File 'lib/groonga/command/base.rb', line 54

def arguments
  @arguments
end

#command_nameString (readonly)

Returns The command name.

Since:

  • 1.1.8



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

def command_name
  @command_name
end

#original_formatObject

Returns the value of attribute original_format.



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

def original_format
  @original_format
end

#original_sourceObject

Returns the value of attribute original_source.



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

def original_source
  @original_source
end

#path_prefixObject

Returns the value of attribute path_prefix.



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

def path_prefix
  @path_prefix
end

Class Method Details

.parameter_namesObject



49
50
51
# File 'lib/groonga/command/base.rb', line 49

def parameter_names
  []
end

Instance Method Details

#==(other) ⇒ Object



89
90
91
92
93
# File 'lib/groonga/command/base.rb', line 89

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

#[](name) ⇒ Object



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

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

#[]=(name, value) ⇒ Object



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

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

#command_format?Boolean



99
100
101
# File 'lib/groonga/command/base.rb', line 99

def command_format?
  @original_format == :command
end

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



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

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

#nameObject

Deprecated.

since 1.1.8. Use #command_name instead.



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

def name
  command_name
end

#output_typeObject



103
104
105
# File 'lib/groonga/command/base.rb', line 103

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

#request_idString?

Returns request_id parameter value.

Since:

  • 1.1.8



110
111
112
# File 'lib/groonga/command/base.rb', line 110

def request_id
  self[:request_id]
end

#to_command_formatObject



118
119
120
# File 'lib/groonga/command/base.rb', line 118

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

#to_uri_formatObject



114
115
116
# File 'lib/groonga/command/base.rb', line 114

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

#uri_format?Boolean



95
96
97
# File 'lib/groonga/command/base.rb', line 95

def uri_format?
  @original_format == :uri
end