Class: Grub::GemLine
- Inherits:
-
Object
- Object
- Grub::GemLine
- Defined in:
- lib/grub/gem_line.rb
Instance Attribute Summary collapse
-
#location ⇒ Object
Returns the value of attribute location.
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#original_line ⇒ Object
Returns the value of attribute original_line.
-
#prev_line_comment ⇒ Object
Returns the value of attribute prev_line_comment.
-
#spec ⇒ Object
Returns the value of attribute spec.
Instance Method Summary collapse
- #comment ⇒ Object
- #info ⇒ Object
-
#initialize(*args) ⇒ GemLine
constructor
A new instance of GemLine.
- #should_insert? ⇒ Boolean
Constructor Details
#initialize(*args) ⇒ GemLine
Returns a new instance of GemLine.
6 7 8 9 10 11 12 13 |
# File 'lib/grub/gem_line.rb', line 6 def initialize(*args) named_params = args.last.respond_to?(:[]) && args.last @name = (named_params && named_params[:name]) || args[0] @original_line = (named_params && named_params[:original_line]) || args[1] @location = (named_params && named_params[:location]) || args[2] @prev_line_comment = (named_params && named_params[:prev_line_comment]) || args[3] @options = (named_params && named_params[:options]) || named_params end |
Instance Attribute Details
#location ⇒ Object
Returns the value of attribute location.
4 5 6 |
# File 'lib/grub/gem_line.rb', line 4 def location @location end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/grub/gem_line.rb', line 4 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/grub/gem_line.rb', line 4 def @options end |
#original_line ⇒ Object
Returns the value of attribute original_line.
4 5 6 |
# File 'lib/grub/gem_line.rb', line 4 def original_line @original_line end |
#prev_line_comment ⇒ Object
Returns the value of attribute prev_line_comment.
4 5 6 |
# File 'lib/grub/gem_line.rb', line 4 def prev_line_comment @prev_line_comment end |
#spec ⇒ Object
Returns the value of attribute spec.
4 5 6 |
# File 'lib/grub/gem_line.rb', line 4 def spec @spec end |
Instance Method Details
#comment ⇒ Object
15 16 17 18 |
# File 'lib/grub/gem_line.rb', line 15 def comment leading_spaces = original_line[0..leading_spaces_count - 1] if leading_spaces_count > 0 comment = "#{leading_spaces}# #{info}" end |
#info ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/grub/gem_line.rb', line 20 def info output = if [:website_only] website elsif [:description_only] description else description_and_website end output << "\n" end |
#should_insert? ⇒ Boolean
31 32 33 |
# File 'lib/grub/gem_line.rb', line 31 def should_insert? !info.strip.empty? && !already_added_comment && !existing_comment_option end |