Class: MethodParser
- Inherits:
-
Object
- Object
- MethodParser
- Defined in:
- lib/method_parser.rb
Instance Attribute Summary collapse
-
#to_a ⇒ Object
readonly
Returns the value of attribute to_a.
Instance Method Summary collapse
-
#initialize(s) ⇒ MethodParser
constructor
A new instance of MethodParser.
- #to_xml ⇒ Object
Constructor Details
#initialize(s) ⇒ MethodParser
Returns a new instance of MethodParser.
13 14 15 16 17 |
# File 'lib/method_parser.rb', line 13 def initialize(s) a = scan Parser::CurrentRuby.parse(s) a2 = flatten_down(a) @to_a = nestify(a2) end |
Instance Attribute Details
#to_a ⇒ Object (readonly)
Returns the value of attribute to_a.
11 12 13 |
# File 'lib/method_parser.rb', line 11 def to_a @to_a end |
Instance Method Details
#to_xml ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/method_parser.rb', line 19 def to_xml xml = RexleBuilder.new a = xml.doc do @to_a.each do |x| container, name, children = x xml.send(container.to_s.sub(/^c/,'k').to_sym, name: name.to_s) do children.each do |y| _, name, scope, args = y[0..2].map(&:to_s) << y[-1] xml.send(y.first, name: name, scope: scope, args: args.join(', ')) end end end end Rexle.new(a).xml pretty: true end |