Class: Yoda::Services::CurrentNodeExplain

Inherits:
Object
  • Object
show all
Defined in:
lib/yoda/services/current_node_explain.rb,
lib/yoda/services/current_node_explain/comment_signature.rb

Overview

CurrentNodeExplain shows help for the current node.

Defined Under Namespace

Classes: CommentSignature

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(evaluator:, location:) ⇒ CurrentNodeExplain

Returns a new instance of CurrentNodeExplain.

Parameters:



27
28
29
30
# File 'lib/yoda/services/current_node_explain.rb', line 27

def initialize(evaluator:, location:)
  @evaluator = evaluator
  @location = location
end

Instance Attribute Details

#evaluatorEvaluator (readonly)

Returns:



8
9
10
# File 'lib/yoda/services/current_node_explain.rb', line 8

def evaluator
  @evaluator
end

#locationParsing::Location (readonly)

Returns:



11
12
13
# File 'lib/yoda/services/current_node_explain.rb', line 11

def location
  @location
end

Class Method Details

.from_source(environment:, source:, location:) ⇒ CurrentNodeExplain

Parameters:

Returns:



17
18
19
20
21
22
23
# File 'lib/yoda/services/current_node_explain.rb', line 17

def self.from_source(environment:, source:, location:)
  ast, _ = Parsing.parse_with_comments(source)
  new(
    evaluator: Evaluator.new(environment: environment, ast: ast),
    location: location
  )
end

Instance Method Details

#current_comment_signatureCommentSignature?

Returns:



39
40
41
42
# File 'lib/yoda/services/current_node_explain.rb', line 39

def current_comment_signature
  return nil if !valid? || !current_comment || !commenting_node_info
  @current_comment_signature ||= CommentSignature.new(comment: current_comment, node_info: commenting_node_info, location: location)
end

#current_node_signatureModel::NodeSignature?

Returns:

  • (Model::NodeSignature, nil)


33
34
35
36
# File 'lib/yoda/services/current_node_explain.rb', line 33

def current_node_signature
  return nil if !valid? || !current_node
  @current_node_signature ||= Model::NodeSignatures.for_node_info(current_node_info)
end

#valid?true, false

Returns:

  • (true, false)


45
46
47
# File 'lib/yoda/services/current_node_explain.rb', line 45

def valid?
  !!(current_comment || current_node)
end