Class: Atomy::Pattern::Equality

Inherits:
Atomy::Pattern show all
Defined in:
lib/atomy/pattern/equality.rb

Instance Attribute Summary collapse

Attributes inherited from Atomy::Pattern

#from_node

Instance Method Summary collapse

Methods inherited from Atomy::Pattern

#===

Constructor Details

#initialize(value) ⇒ Equality

Returns a new instance of Equality.



7
8
9
# File 'lib/atomy/pattern/equality.rb', line 7

def initialize(value)
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



5
6
7
# File 'lib/atomy/pattern/equality.rb', line 5

def value
  @value
end

Instance Method Details

#inline_matches?(gen) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
# File 'lib/atomy/pattern/equality.rb', line 15

def inline_matches?(gen)
  push_value(gen)
  gen.swap
  gen.send(:==, 1)
end

#matches?(val) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/atomy/pattern/equality.rb', line 11

def matches?(val)
  @value == val
end

#targetObject



21
22
23
# File 'lib/atomy/pattern/equality.rb', line 21

def target
  @value.class
end