Class: Aef::Hosts::Comment
Overview
Represents a comment-only line as element of a hosts file
Instance Attribute Summary collapse
-
#comment ⇒ String
The comment.
Attributes inherited from Element
Instance Method Summary collapse
-
#generate_string(options = {}) ⇒ String
protected
Defines the algorithm to generate a String representation from scratch.
-
#initialize(comment, options = {}) ⇒ Comment
constructor
Initializes a comment.
-
#inspect ⇒ String
A String representation for debugging purposes.
Methods inherited from Element
#cache_filled?, #cache_string, #invalidate_cache!, #to_s
Constructor Details
#initialize(comment, options = {}) ⇒ Comment
Initializes a comment
38 39 40 41 42 43 44 45 |
# File 'lib/aef/hosts/comment.rb', line 38 def initialize(comment, = {}) (, :cache) raise ArgumentError, 'Comment cannot be empty' unless comment @comment = comment.to_s @cache = [:cache].to_s unless [:cache].nil? end |
Instance Attribute Details
#comment ⇒ String
The comment
31 32 33 |
# File 'lib/aef/hosts/comment.rb', line 31 def comment @comment end |
Instance Method Details
#generate_string(options = {}) ⇒ String (protected)
Defines the algorithm to generate a String representation from scratch.
66 67 68 |
# File 'lib/aef/hosts/comment.rb', line 66 def generate_string( = {}) "##{comment}\n" end |
#inspect ⇒ String
A String representation for debugging purposes
57 58 59 |
# File 'lib/aef/hosts/comment.rb', line 57 def inspect generate_inspect(self, :comment, :cache) end |