Class: TestParser::Snippet

Inherits:
Object
  • Object
show all
Defined in:
lib/test_parser/snippet.rb

Direct Known Subclasses

SourceCode

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sexp) ⇒ Snippet

Returns a new instance of Snippet.

Raises:

  • (ArgumentError)


8
9
10
11
# File 'lib/test_parser/snippet.rb', line 8

def initialize(sexp)
  raise ArgumentError unless sexp
  @sexp = sexp
end

Instance Attribute Details

#sexpObject (readonly)

Returns the value of attribute sexp.



6
7
8
# File 'lib/test_parser/snippet.rb', line 6

def sexp
  @sexp
end

Instance Method Details

#get_blockObject



17
18
19
# File 'lib/test_parser/snippet.rb', line 17

def get_block
  Snippet.new(sexp[3])
end

#to_codeObject



13
14
15
# File 'lib/test_parser/snippet.rb', line 13

def to_code
  @to_code ||= Ruby2Ruby.new.process(sexp.deep_clone)
end