Class: Wandbox::Compiler
- Inherits:
-
Hash
- Object
- Hash
- Wandbox::Compiler
- Includes:
- Iolite::Adaptor::ToLazy, Iolite::Placeholders
- Defined in:
- lib/wandbox/compiler.rb
Class Method Summary collapse
Instance Method Summary collapse
- #find_option_by_name(name) ⇒ Object
-
#initialize(data) ⇒ Compiler
constructor
A new instance of Compiler.
- #options ⇒ Object
- #to_stdio(enable_options = []) ⇒ Object
Constructor Details
#initialize(data) ⇒ Compiler
Returns a new instance of Compiler.
11 12 13 |
# File 'lib/wandbox/compiler.rb', line 11 def initialize data data.each { |key, value| self[key] = value } end |
Class Method Details
Instance Method Details
#find_option_by_name(name) ⇒ Object
30 31 32 |
# File 'lib/wandbox/compiler.rb', line 30 def find_option_by_name name .find &arg1["name"] == name end |
#options ⇒ Object
25 26 27 28 |
# File 'lib/wandbox/compiler.rb', line 25 def = self["switches"].select &arg1["type"] == "single" + self["switches"].select(&arg1["type"] == "select").map(&arg1["options"]).flatten end |
#to_stdio(enable_options = []) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/wandbox/compiler.rb', line 34 def to_stdio =[] opts = opts.reject! &arg1["display-flags"].empty? opts.sort_by! &arg1["name"] width = (opts.max_by(&arg1["name"].length) || { "name" => "" })["name"].length = .map(&to_l.find_option_by_name(arg1)).compact.map(&arg1["display-flags"]).join " " <<"EOS" [Compiler]: #{self["display-name"]} [Language]: #{self["language"]} [Version]: #{self["version"]} [Compiler command]: $ #{self["display-compile-command"]}#{ " " + unless .empty?} #{ unless opts.empty? <<"EOS" [Option list]: #{"Option name".ljust width + 1} : Added extra option #{ opts.map { |it| " #{it["name"].ljust width + 1} : #{it["display-flags"]}" }.join "\n" } EOS end } EOS end |