Class: RBNF::RepN
Overview
Repetition (n times) node
Constant Summary
Constants included from RBNF
Instance Attribute Summary
Attributes inherited from Binary
Instance Method Summary collapse
Methods inherited from Binary
Methods included from RBNF
#=~, [], #alt, #cat, #comps, def, define, dememoize, #except, #group, method_missing, #opt, #rep, #rep_n
Constructor Details
This class inherits a constructor from RBNF::Binary
Instance Method Details
#match(s) ⇒ Object
101 102 103 104 105 106 107 108 109 |
# File 'lib/rbnf/nodes.rb', line 101 def match(s) if b==0 s.empty? elsif Integer===b and b>0 (2..b).inject(a) {|r| r.cat a}=~s else raise ArgumentError, "can't repeat #{a} #{b} times" end end |
#to_s ⇒ Object
98 99 100 |
# File 'lib/rbnf/nodes.rb', line 98 def to_s "#{b} * #{a}" end |