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
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
#transform ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# 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").map(&:strip) deactivated_lines = [] config.each do |line| # .xsd doesn't include "apply-groups" apply_groups = trim_apply_groups(line) if line == 'set' @config << apply_groups next end if line =~ /^deactivate *(.*)/ deactivated_lines << "#$1 #{apply_groups}".strip next end transformed = transform.apply(parser.parse(line)) raise "ERROR: Failed to parse \"#{line}\"" unless transformed.is_a?(String) if apply_groups transformed << "\n#{apply_groups}" end @config << transformed end deactivated_lines.each {|l| @config.deactivate l } @config.to_s end |