Class: TEALrb::TEAL
- Inherits:
-
Array
- Object
- Array
- TEALrb::TEAL
- Defined in:
- lib/tealrb.rb
Instance Method Summary collapse
- #<<(value) ⇒ Object
- #boolean_and(_other) ⇒ Object
- #boolean_or(_other) ⇒ Object
-
#initialize(teal_array, contract) ⇒ TEAL
constructor
A new instance of TEAL.
- #src_map(file, line_number) ⇒ Object
- #teal ⇒ Object
Constructor Details
#initialize(teal_array, contract) ⇒ TEAL
Returns a new instance of TEAL.
36 37 38 39 |
# File 'lib/tealrb.rb', line 36 def initialize(teal_array, contract) @contract = contract super(teal_array) end |
Instance Method Details
#<<(value) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/tealrb.rb', line 49 def <<(value) return super unless @contract.class.src_map return super if caller.join['src_map'] return super unless @contract.eval_location eval_location = caller.reverse.find { _1[/^\(eval/] }&.split(':') return super unless eval_location eval_line = eval_location[1].to_i src_map(@contract.eval_location.first, @contract.eval_location.last + eval_line) super end |
#boolean_and(_other) ⇒ Object
45 46 47 |
# File 'lib/tealrb.rb', line 45 def boolean_and(_other) self << '&&' end |
#boolean_or(_other) ⇒ Object
71 72 73 |
# File 'lib/tealrb.rb', line 71 def boolean_or(_other) self << '||' end |
#src_map(file, line_number) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/tealrb.rb', line 62 def src_map(file, line_number) ln = "// src_map:#{File.basename(file)}:#{line_number}" return if ln == @last_src_map @last_src_map = ln self << ln end |
#teal ⇒ Object
41 42 43 |
# File 'lib/tealrb.rb', line 41 def teal flatten end |