Class: Simple::Service::Action::Comment

Inherits:
Object
  • Object
show all
Defined in:
lib/simple/service/action/comment.rb

Overview

returns the comment for an action

Defined Under Namespace

Modules: Extractor

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(short:, full:) ⇒ Comment

Returns a new instance of Comment.



15
16
17
# File 'lib/simple/service/action/comment.rb', line 15

def initialize(short:, full:)
  @short, @full = short, full
end

Instance Attribute Details

#fullObject (readonly)

Returns the value of attribute full.



6
7
8
# File 'lib/simple/service/action/comment.rb', line 6

def full
  @full
end

#shortObject (readonly)



5
6
7
# File 'lib/simple/service/action/comment.rb', line 5

def short
  @short
end

Class Method Details

.extract(action:) ⇒ Object



8
9
10
11
12
13
# File 'lib/simple/service/action/comment.rb', line 8

def self.extract(action:)
  file, line = action.source_location
  lines = Extractor.extract_comment_lines(file: file, before_line: line)
  full = lines[2..-1].join("\n") if lines.length >= 2
  new short: lines[0], full: full
end