Class: Org::Scope
- Inherits:
-
Object
- Object
- Org::Scope
- Defined in:
- lib/org/scope.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#scopes ⇒ Object
Returns the value of attribute scopes.
Instance Method Summary collapse
- #apply {|_self| ... } ⇒ Object
-
#initialize(name, options = {}) ⇒ Scope
constructor
A new instance of Scope.
- #inspect ⇒ Object
- #rule(name, regex, options = {}) ⇒ Object
- #scope(name, options = {}) {|@scopes[name] = scope| ... } ⇒ Object
- #step(state) ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ Scope
Returns a new instance of Scope.
5 6 7 8 9 |
# File 'lib/org/scope.rb', line 5 def initialize(name, = {}) @rules = [] @name, @options = name, @scopes = {} end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/org/scope.rb', line 3 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
3 4 5 |
# File 'lib/org/scope.rb', line 3 def parent @parent end |
#scopes ⇒ Object
Returns the value of attribute scopes.
3 4 5 |
# File 'lib/org/scope.rb', line 3 def scopes @scopes end |
Instance Method Details
#apply {|_self| ... } ⇒ Object
21 22 23 |
# File 'lib/org/scope.rb', line 21 def apply yield(self) end |
#inspect ⇒ Object
31 32 33 |
# File 'lib/org/scope.rb', line 31 def inspect "<Scope #{name}>" end |
#rule(name, regex, options = {}) ⇒ Object
17 18 19 |
# File 'lib/org/scope.rb', line 17 def rule(name, regex, = {}) @rules << Rule.new(name, regex, ) end |
#scope(name, options = {}) {|@scopes[name] = scope| ... } ⇒ Object
11 12 13 14 15 |
# File 'lib/org/scope.rb', line 11 def scope(name, = {}, &block) scope = Scope.new(name, ) scope.parent = self yield @scopes[name] = scope end |
#step(state) ⇒ Object
25 26 27 28 29 |
# File 'lib/org/scope.rb', line 25 def step(state) @rules.find do |rule| rule.match(state) end end |