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
913 914 915 916 917 918 919 920 921 |
# File 'lib/delorean/nodes.rb', line 913 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
948 949 950 |
# File 'lib/delorean/nodes.rb', line 948 def condition? defined?(ifexp.e3) end |
#conditions? ⇒ Boolean
952 953 954 955 956 957 958 |
# File 'lib/delorean/nodes.rb', line 952 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
923 924 925 926 927 928 929 930 931 932 933 934 |
# File 'lib/delorean/nodes.rb', line 923 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
936 937 938 939 940 941 942 |
# File 'lib/delorean/nodes.rb', line 936 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
944 945 946 |
# File 'lib/delorean/nodes.rb', line 944 def splat? defined?(splat) end |
#splats? ⇒ Boolean
960 961 962 963 964 965 966 |
# File 'lib/delorean/nodes.rb', line 960 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 |