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

Returns a new instance of Base.



60
61
62
63
64
65
66
# File 'lib/groonga/command/base.rb', line 60

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.



58
59
60
# File 'lib/groonga/command/base.rb', line 58

def arguments
  @arguments
end

#command_nameString (readonly)

Returns The command name.

Returns:

  • (String)

    The command name.

Since:

  • 1.1.8



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

def command_name
  @command_name
end

#original_formatObject

Returns the value of attribute original_format.



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

def original_format
  @original_format
end

#original_sourceObject

Returns the value of attribute original_source.



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

def original_source
  @original_source
end

#path_prefixObject

Returns the value of attribute path_prefix.



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

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



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

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

#[](name) ⇒ Object



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

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

#[]=(name, value) ⇒ Object



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

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

#command_format?Boolean

Returns:

  • (Boolean)


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

def command_format?
  @original_format == :command
end

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

Returns:

  • (Boolean)


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

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

#nameObject

Deprecated.

since 1.1.8. Use #command_name instead.



69
70
71
# File 'lib/groonga/command/base.rb', line 69

def name
  command_name
end

#output_typeObject



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

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

#request_idString?

Returns request_id parameter value.

Returns:

  • (String, nil)

    request_id parameter value.

Since:

  • 1.1.8



107
108
109
# File 'lib/groonga/command/base.rb', line 107

def request_id
  self[:request_id]
end

#to_command_formatObject



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

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

#to_uri_formatObject



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

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

#uri_format?Boolean

Returns:

  • (Boolean)


92
93
94
# File 'lib/groonga/command/base.rb', line 92

def uri_format?
  @original_format == :uri
end