Class: Elm::Options

Inherits:
Object
  • Object
show all
Includes:
Contracts::Builtin, Contracts::Core
Defined in:
lib/elm/options.rb

Overview

Options to run elm

Constant Summary collapse

FORMATS =
[:normal, :json].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOptions

Returns a new instance of Options.



44
45
46
47
48
49
50
51
52
# File 'lib/elm/options.rb', line 44

def initialize
  @output = 'index.html'
  @yes = false
  @report = :normal
  @warn = false
  @docs = nil

  self
end

Instance Attribute Details

#docsObject

Returns the value of attribute docs.



41
42
43
# File 'lib/elm/options.rb', line 41

def docs
  @docs
end

#outputObject

Returns the value of attribute output.



41
42
43
# File 'lib/elm/options.rb', line 41

def output
  @output
end

#reportObject

Returns the value of attribute report.



41
42
43
# File 'lib/elm/options.rb', line 41

def report
  @report
end

#warnObject

Returns the value of attribute warn.



41
42
43
# File 'lib/elm/options.rb', line 41

def warn
  @warn
end

#yesObject

Returns the value of attribute yes.



41
42
43
# File 'lib/elm/options.rb', line 41

def yes
  @yes
end

Class Method Details

.clone(opts) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/elm/options.rb', line 31

def self.clone(opts)
  Options.with(output: opts.output,
               yes: opts.yes,
               report: opts.report,
               warn: opts.warn,
               docs: opts.docs)
end

.with(output: 'index.html', yes: false, report: :normal, warn: false, docs: nil) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/elm/options.rb', line 19

def self.with(output: 'index.html', yes: false, report: :normal,
              warn: false, docs: nil)
  opts = Options.new
  opts.output = output
  opts.yes = yes
  opts.report = report
  opts.warn = warn
  opts.docs = docs unless docs.nil?
  opts
end

Instance Method Details

#to_aObject



86
87
88
89
90
91
92
93
94
# File 'lib/elm/options.rb', line 86

def to_a
  res = []
  push_output res
  push_yes res
  push_report res
  push_warn res
  push_docs res
  res
end

#with_docs(docs) ⇒ Object



125
126
127
128
129
# File 'lib/elm/options.rb', line 125

def with_docs(docs)
  opts = Options.clone self
  opts.docs = docs
  opts
end

#with_output(output) ⇒ Object



97
98
99
100
101
# File 'lib/elm/options.rb', line 97

def with_output(output)
  opts = Options.clone self
  opts.output = output
  opts
end

#with_report(report) ⇒ Object



111
112
113
114
115
# File 'lib/elm/options.rb', line 111

def with_report(report)
  opts = Options.clone self
  opts.report = report
  opts
end

#with_warnObject



118
119
120
121
122
# File 'lib/elm/options.rb', line 118

def with_warn
  opts = Options.clone self
  opts.warn = true
  opts
end

#with_yesObject



104
105
106
107
108
# File 'lib/elm/options.rb', line 104

def with_yes
  opts = Options.clone self
  opts.yes = true
  opts
end