Class: RedParse::StringCatNode
- Defined in:
- lib/redparse/node.rb,
lib/redparse/node.rb
Constant Summary
Constants included from FlattenedIvars
FlattenedIvars::EXCLUDED_IVARS
Instance Attribute Summary
Attributes inherited from Node
#endline, #errors, #offset, #parent, #startline
Attributes included from RedParse::Stackable::Meta
#boolean_identity_params, #identity_params
Instance Method Summary collapse
-
#initialize(*strses) ⇒ StringCatNode
constructor
A new instance of StringCatNode.
- #parsetree(o) ⇒ Object
- #unparse(o = default_unparse_options) ⇒ Object
Methods inherited from ValueNode
Methods inherited from Node
#+, #+@, #==, [], #[]=, #add_parent_links!, #begin_parsetree, create, #data, #deep_copy, #delete_extraneous_ivars!, #delete_linenums!, #depthwalk, #depthwalk_nodes, #error?, #evalable_inspect, #fixup_multiple_assignments!, #fixup_rescue_assignments!, #image, #initialize_ivars, inline_symbols, #inspect, #lhs_unparse, #linerange, #lvalue, #lvars_defined_in, #merge_replacement_session, namelist, #negate, #original_brackets_assign, param_names, #parsetrees, #pretty_print, #prohibit_fixup, #replace_ivars_and_self, #replace_value, #rescue_parsetree, #to_parsetree, #to_parsetree_and_warnings, #unary, #walk, #xform_tree!
Methods included from RedParse::Stackable::Meta
#build_exemplars, #enumerate_exemplars, #identity_param
Methods included from FlattenedIvars
#flattened_ivars, #flattened_ivars_equal?
Methods included from Stackable
Constructor Details
#initialize(*strses) ⇒ StringCatNode
Returns a new instance of StringCatNode.
1531 1532 1533 1534 1535 1536 1537 |
# File 'lib/redparse/node.rb', line 1531 def initialize(*strses) strs=strses.pop.unshift( *strses ) hd=strs.shift if HereDocNode===strs.first strs.map!{|str| StringNode.new(str)} strs.unshift hd if hd super( *strs ) end |
Instance Method Details
#parsetree(o) ⇒ Object
1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 |
# File 'lib/redparse/node.rb', line 1538 def parsetree(o) result=map{|str| str.parsetree(o)} sum='' type=:str tree=i=nil result.each_with_index{|tree2,i2| tree,i=tree2,i2 sum+=tree[1] tree.first==:str or break(type=:dstr) } [type,sum,*tree[2..-1]+result[i+1..-1].inject([]){|cat,x| if x.first==:dstr x.shift x0=x[0] if x0=='' and x.size==2 x.shift else x[0]=[:str,x0] end cat+x elsif x.last.empty? cat else cat+[x] end } ] end |
#unparse(o = default_unparse_options) ⇒ Object
1566 1567 1568 |
# File 'lib/redparse/node.rb', line 1566 def unparse o= map{|ss| ss.unparse(o)}.join ' ' end |