Class: Junoser::Display::Structure

Inherits:
Object
  • Object
show all
Defined in:
lib/junoser/display/structure.rb

Instance Method Summary collapse

Constructor Details

#initialize(io_or_string) ⇒ Structure

Returns a new instance of Structure.



9
10
11
12
# File 'lib/junoser/display/structure.rb', line 9

def initialize(io_or_string)
  @input = io_or_string
  @config = Junoser::Display::ConfigStore.new
end

Instance Method Details

#transformObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/junoser/display/structure.rb', line 14

def transform
  parser = Junoser::Parser.new
  transform = Junoser::Transformer.new

  Junoser::Input.new(@input).read.split("\n").each do |line|
    transformed = transform.apply(parser.parse(line))
    raise "ERROR: parse failed" unless transformed.is_a?(String)
    @config << transformed
  end

  @config.to_s
end