Class: Pwl::Message
- Inherits:
-
Object
- Object
- Pwl::Message
- Defined in:
- lib/pwl/message.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#exit_code ⇒ Object
readonly
Returns the value of attribute exit_code.
Instance Method Summary collapse
- #error? ⇒ Boolean
-
#initialize(template, exit_code = 0, default_replacements = {}) ⇒ Message
constructor
A new instance of Message.
- #to_s(replacements = {}) ⇒ Object
Constructor Details
#initialize(template, exit_code = 0, default_replacements = {}) ⇒ Message
Returns a new instance of Message.
17 18 19 20 21 |
# File 'lib/pwl/message.rb', line 17 def initialize(template, exit_code = 0, default_replacements = {}) @template = ERB.new(template) @exit_code = exit_code @default_replacements = default_replacements end |
Instance Attribute Details
#exit_code ⇒ Object (readonly)
Returns the value of attribute exit_code.
15 16 17 |
# File 'lib/pwl/message.rb', line 15 def exit_code @exit_code end |
Instance Method Details
#error? ⇒ Boolean
31 32 33 |
# File 'lib/pwl/message.rb', line 31 def error? false end |
#to_s(replacements = {}) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/pwl/message.rb', line 23 def to_s(replacements = {}) if !replacements.any? && @default_replacements.any? @template.result(@default_replacements.to_binding) else @template.result(replacements.to_binding) end end |