Class: Junoser::Display::Structure
- Inherits:
-
Object
- Object
- Junoser::Display::Structure
- Defined in:
- lib/junoser/display/structure.rb
Instance Method Summary collapse
-
#initialize(io_or_string) ⇒ Structure
constructor
A new instance of Structure.
- #transform ⇒ Object
Constructor Details
#initialize(io_or_string) ⇒ 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
#transform ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/junoser/display/structure.rb', line 14 def transform parser = Junoser::Parser.new transform = Junoser::Transformer.new config = Junoser::Input.new(@input).read.split("\n") deactivated_lines = config.grep(/^deactivate /).map {|l| l.sub(/^deactivate /, '') } config.each do |line| next if line =~ /^deactivate / transformed = transform.apply(parser.parse(line)) raise "ERROR: parse failed" unless transformed.is_a?(String) @config << transformed end deactivated_lines.each {|l| @config.deactivate l } @config.to_s end |