Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/onebot-ruby.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *a) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/onebot-ruby.rb', line 8

def method_missing(m, *a)
  if m.to_s =~ /=$/
    self[Regexp.last_match.pre_match] = a[0]
  elsif a.empty?
    self[m]
  else
    super
  end
end

Instance Method Details

#respond_to_missing?(m, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/onebot-ruby.rb', line 18

def respond_to_missing?(m, include_private = false)
  super unless m.to_s =~ /=$/
end