Class: Delorean::HashArgs
- Defined in:
- lib/delorean/nodes.rb
Instance Method Summary collapse
- #check(context) ⇒ Object
- #condition? ⇒ Boolean
- #conditions? ⇒ Boolean
- #rewrite(context, var) ⇒ Object
- #rewrite_with_literal(context) ⇒ Object
- #splat? ⇒ Boolean
- #splats? ⇒ Boolean
Instance Method Details
#check(context) ⇒ Object
841 842 843 844 845 846 847 848 849 |
# File 'lib/delorean/nodes.rb', line 841 def check(context, *) [ e0.check(context), (e1.check(context) unless defined?(splat)), (ifexp.e3.check(context) if defined?(ifexp.e3)), (args_rest.al.check(context) if defined?(args_rest.al) && !args_rest.al.empty?), ].compact.sum end |
#condition? ⇒ Boolean
876 877 878 |
# File 'lib/delorean/nodes.rb', line 876 def condition? defined?(ifexp.e3) end |
#conditions? ⇒ Boolean
880 881 882 883 884 885 886 |
# File 'lib/delorean/nodes.rb', line 880 def conditions? return true if condition? return false unless defined?(args_rest.al) return false if args_rest.al.text_value.empty? args_rest.al.conditions? end |
#rewrite(context, var) ⇒ Object
851 852 853 854 855 856 857 858 859 860 861 862 |
# File 'lib/delorean/nodes.rb', line 851 def rewrite(context, var) res = if splat? "#{var}.merge!(#{e0.rewrite(context)})" else "#{var}[#{e0.rewrite(context)}]=(#{e1.rewrite(context)})" end res += " if (#{ifexp.e3.rewrite(context)})" if condition? res += ';' res += args_rest.al.rewrite(context, var) if defined?(args_rest.al) && !args_rest.al.text_value.empty? res end |
#rewrite_with_literal(context) ⇒ Object
864 865 866 867 868 869 870 |
# File 'lib/delorean/nodes.rb', line 864 def rewrite_with_literal(context) res = "#{e0.rewrite(context)} => #{e1.rewrite(context)}," res += args_rest.al.rewrite_with_literal(context) if defined?(args_rest.al) && !args_rest.al.text_value.empty? res end |
#splat? ⇒ Boolean
872 873 874 |
# File 'lib/delorean/nodes.rb', line 872 def splat? defined?(splat) end |
#splats? ⇒ Boolean
888 889 890 891 892 893 894 |
# File 'lib/delorean/nodes.rb', line 888 def splats? return true if splat? return false unless defined?(args_rest.al) return false if args_rest.al.text_value.empty? args_rest.al.splats? end |