Class: Anystyle::Parser::Feature

Inherits:
Object
  • Object
show all
Defined in:
lib/anystyle/parser/features.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, matcher) ⇒ Feature

Returns a new instance of Feature.



27
28
29
# File 'lib/anystyle/parser/features.rb', line 27

def initialize(name, matcher)
  @name, @matcher = name, matcher
end

Class Attribute Details

.dictObject (readonly)

Returns the value of attribute dict.



13
14
15
# File 'lib/anystyle/parser/features.rb', line 13

def dict
  @dict
end

.instancesObject (readonly)

Returns the value of attribute instances.



13
14
15
# File 'lib/anystyle/parser/features.rb', line 13

def instances
  @instances
end

Instance Attribute Details

#matcherObject

Returns the value of attribute matcher.



25
26
27
# File 'lib/anystyle/parser/features.rb', line 25

def matcher
  @matcher
end

#nameObject

Returns the value of attribute name.



25
26
27
# File 'lib/anystyle/parser/features.rb', line 25

def name
  @name
end

Class Method Details

.define(name, &block) ⇒ Object



15
16
17
# File 'lib/anystyle/parser/features.rb', line 15

def define(name, &block)
  instances << new(name, block)
end

.undefine(name) ⇒ Object



19
20
21
# File 'lib/anystyle/parser/features.rb', line 19

def undefine(name)
  instances.reject! { |f| f.name == name }
end

Instance Method Details

#match(*arguments) ⇒ Object



31
32
33
# File 'lib/anystyle/parser/features.rb', line 31

def match(*arguments)
  matcher.call(*arguments)
end