Class: Junoser::Display::Set

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

Instance Method Summary collapse

Constructor Details

#initialize(io_or_string) ⇒ Set

Returns a new instance of Set.



7
8
9
# File 'lib/junoser/display/set.rb', line 7

def initialize(io_or_string)
  @input = io_or_string
end

Instance Method Details

#commit_check(&block) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/junoser/display/set.rb', line 21

def commit_check(&block)
  parser = Junoser::Parser.new
  passed = true

  process do |current_stack, str|
    config = transform_line(current_stack, str)

    begin
      parser.parse config
    rescue Parslet::ParseFailed
      $stderr.puts "Invalid syntax:  #{config}"
      passed = false
    end
  end

rescue
  $stderr.puts $!
  passed = false
ensure
  return passed
end

#transformObject



11
12
13
14
15
16
17
18
19
# File 'lib/junoser/display/set.rb', line 11

def transform
  result = ''

  process do |current_stack, str|
    result << transform_line(current_stack, str) << "\n"
  end

  result
end