Class: Junoser::Display::Structure

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

Instance Attribute Summary

Attributes included from Base

#output

Instance Method Summary collapse

Constructor Details

#initialize(io_or_string) ⇒ Structure

Returns a new instance of Structure.



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

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

Instance Method Details

#transformObject



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

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

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

  @output.puts @config.to_s
end