Class: Sorcerer::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/sorcerer/resource.rb

Defined Under Namespace

Classes: NoHandlerError, NotSexpError, SorcererError, UnexpectedSexpError

Instance Method Summary collapse

Constructor Details

#initialize(sexp, options = {}) ⇒ Resource

Returns a new instance of Resource.



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sorcerer/resource.rb', line 19

def initialize(sexp, options={})
  @sexp = sexp
  @debug = options[:debug]
  @indent = options[:indent] || 0
  @indent = 2 if @indent && ! @indent.is_a?(Integer)
  @multiline = options[:multiline] || indenting?

  @source = ''
  @word_level = 0
  @stack = []
  @level = 0
  @virgin_line = true
end

Instance Method Details

#sourceObject



33
34
35
36
37
38
39
40
# File 'lib/sorcerer/resource.rb', line 33

def source
  @stack.clear
  resource(@sexp)
  if multiline?
    @source << "\n" unless @source =~ /\n\z/m
  end
  @source
end