Class: ActionView::RenderParser::RipperRenderParser::Node
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
::Array
|
|
Instance Chain:
self,
::Array
|
|
Inherits: | Array |
Defined in: | actionview/lib/action_view/render_parser/ripper_render_parser.rb |
Class Method Summary
- .new(type, arr, opts = {}) ⇒ Node constructor
::Array
- Inherited
.wrap | Wraps its argument in an array unless it is already an array (or array-like). |
Instance Attribute Summary
- #call? ⇒ Boolean readonly
- #fcall? ⇒ Boolean readonly
- #hash? ⇒ Boolean readonly
- #string? ⇒ Boolean readonly
- #symbol? ⇒ Boolean readonly
- #type readonly
- #variable_reference? ⇒ Boolean readonly
- #vcall? ⇒ Boolean readonly
::Array
- Inherited
Instance Method Summary
- #argument_nodes
- #call_method_name
- #children
- #fcall_named?(name) ⇒ Boolean
- #hash_from_body(body)
- #inspect
- #to_hash
- #to_string
- #to_symbol
- #variable_name
::Array
- Inherited
#blank? | An array is blank if it’s empty: |
#deep_dup | Returns a deep copy of array. |
#excluding | Returns a copy of the |
#extract! | Removes and returns the elements for which the block returns a true value. |
#extract_options! | Extracts options from a set of arguments. |
#fifth | Equal to |
#forty_two | Equal to |
#fourth | Equal to |
#from | Returns the tail of the array from |
#in_groups | Splits or iterates over the array in |
#in_groups_of | Splits or iterates over the array in groups of size |
#including | Returns a new array that includes the passed elements. |
#inquiry | Wraps the array in an |
#second | Equal to |
#second_to_last | Equal to |
#split | Divides the array into one or more subarrays based on a delimiting |
#third | Equal to |
#third_to_last | Equal to |
#to | Returns the beginning of the array up to |
#to_formatted_s | Alias for Array#to_fs. |
#to_fs | Extends |
#to_param | Calls |
#to_query | Converts an array into a string suitable for use as a URL query string, using the given |
#to_sentence | Converts the array to a comma-separated sentence where the last element is joined by the connector word. |
#to_xml | Returns a string that represents the array in XML by invoking |
#without | Alias for Array#excluding. |
#as_json, | |
#compact_blank! | Removes all blank elements from the |
Constructor Details
.new(type, arr, opts = {}) ⇒ Node
Instance Attribute Details
#call? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'actionview/lib/action_view/render_parser/ripper_render_parser.rb', line 55
def call? type == :call end
#fcall? ⇒ Boolean
(readonly)
[ GitHub ]
#hash? ⇒ Boolean
(readonly)
[ GitHub ]
#string? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'actionview/lib/action_view/render_parser/ripper_render_parser.rb', line 43
def string? type == :string_literal end
#symbol? ⇒ Boolean
(readonly)
[ GitHub ]
#type (readonly)
[ GitHub ]# File 'actionview/lib/action_view/render_parser/ripper_render_parser.rb', line 7
attr_reader :type
#variable_reference? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'actionview/lib/action_view/render_parser/ripper_render_parser.rb', line 47
def variable_reference? type == :var_ref end
#vcall? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'actionview/lib/action_view/render_parser/ripper_render_parser.rb', line 51
def vcall? type == :vcall end
Instance Method Details
#argument_nodes
[ GitHub ]#call_method_name
[ GitHub ]# File 'actionview/lib/action_view/render_parser/ripper_render_parser.rb', line 63
def call_method_name self[2].first end
#children
[ GitHub ]# File 'actionview/lib/action_view/render_parser/ripper_render_parser.rb', line 14
def children to_a end
#fcall_named?(name) ⇒ Boolean
#hash_from_body(body)
[ GitHub ]# File 'actionview/lib/action_view/render_parser/ripper_render_parser.rb', line 95
def hash_from_body(body) body.to_h do |hash_node| return nil if hash_node.type != :assoc_new [hash_node[0], hash_node[1]] end end
#inspect
[ GitHub ]#to_hash
[ GitHub ]# File 'actionview/lib/action_view/render_parser/ripper_render_parser.rb', line 85
def to_hash if type == : hash_from_body(self[0]) elsif type == :hash && self[0] == nil {} elsif type == :hash && self[0].type == :assoclist_from_args hash_from_body(self[0][0]) end end
#to_string
[ GitHub ]#to_symbol
[ GitHub ]# File 'actionview/lib/action_view/render_parser/ripper_render_parser.rb', line 107
def to_symbol if type == :@label && self[0] =~ /\A(.+):\z/ $1.to_sym elsif type == :symbol_literal && self[0].type == :symbol && self[0][0].type == :@ident self[0][0][0].to_sym else raise "not a symbol?: #{self.inspect}" end end
#variable_name
[ GitHub ]# File 'actionview/lib/action_view/render_parser/ripper_render_parser.rb', line 59
def variable_name self[0][0] end