Class: Rekkyo::Type::Member

Inherits:
Object
  • Object
show all
Defined in:
lib/rekkyo/type/member.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, value) ⇒ Member

Returns a new instance of Member.



8
9
10
11
# File 'lib/rekkyo/type/member.rb', line 8

def initialize(key, value)
  @key = key
  @value = value
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



6
7
8
# File 'lib/rekkyo/type/member.rb', line 6

def key
  @key
end

#valueObject (readonly)

Returns the value of attribute value.



6
7
8
# File 'lib/rekkyo/type/member.rb', line 6

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



13
14
15
16
17
# File 'lib/rekkyo/type/member.rb', line 13

def ==(other)
  self.class == other.class &&
    self.key == other.key &&
    self.value == other.value
end

#as_json(options = nil) ⇒ Object



41
42
43
# File 'lib/rekkyo/type/member.rb', line 41

def as_json(options = nil)
  self.to_s.as_json(options)
end

#inspectObject



32
33
34
# File 'lib/rekkyo/type/member.rb', line 32

def inspect
  "#{self.class.name || ''}::#{key}(#{value.inspect})"
end

#match?(other) ⇒ Boolean Also known as: ===

Returns:

  • (Boolean)


19
20
21
22
23
24
25
26
27
28
# File 'lib/rekkyo/type/member.rb', line 19

def match?(other)
  case other
  when self.class
    self == other
  when String, Symbol
    self.value.to_s == other.to_s
  else
    self.value == other
  end
end

#to_sObject



36
37
38
# File 'lib/rekkyo/type/member.rb', line 36

def to_s
  self.value.to_s
end