Sha256: c0e03e41aa5efd00f03d60679c14e0ca7f46b7d4c5134c52e9c30e0c06299b7c

Contents?: true

Size: 787 Bytes

Versions: 2

Compression:

Stored size: 787 Bytes

Contents

module Vedeu
  class MenuParser
    def self.parse(args)
      new(args).parse
    end

    def initialize(args)
      @args = args
    end

    def parse
      { interfaces: interface }
    end

    private

    attr_reader :args

    def interface
      { name: name, lines: lines }
    end

    def lines
      lines = []
      items.each do |sel, cur, item|
        if sel && cur
          lines << { streams: { text: "*> #{item}" } }

        elsif cur
          lines << { streams: { text: " > #{item}" } }

        elsif sel
          lines << { streams: { text: "*  #{item}" } }

        else
          lines << { streams: { text: "   #{item}" } }

        end
      end
      lines
    end

    def items
      args.last
    end

    def name
      args.first
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vedeu-0.1.6 lib/vedeu/output/menu_parser.rb
vedeu-0.1.5 lib/vedeu/output/menu_parser.rb