Class: CodeModels::EmbeddedArtifact

Inherits:
Artifact
  • Object
show all
Defined in:
lib/codemodels/artifact.rb

Overview

Represent a snippet embedded in something else

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Artifact

#initialize, #point_to_absolute, #position_to_absolute

Constructor Details

This class inherits a constructor from CodeModels::Artifact

Instance Attribute Details

#host_artifactObject

Returns the value of attribute host_artifact.



38
39
40
# File 'lib/codemodels/artifact.rb', line 38

def host_artifact
  @host_artifact
end

#position_in_hostObject

Returns the value of attribute position_in_host.



39
40
41
# File 'lib/codemodels/artifact.rb', line 39

def position_in_host
  @position_in_host
end

Instance Method Details

#absolute_startObject



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/codemodels/artifact.rb', line 41

def absolute_start
  p = host_artifact.absolute_start
  p.line += position_in_host.begin_point.line-1
  if position_in_host.begin_point.line==1      
    # if I am on the first line of my "host", its column
    # matters because there are not newlines to reset the column
    # counter
    p.column += position_in_host.begin_point.column-1 
  else
    p.column = position_in_host.begin_point.column
  end
  p
end

#codeObject



63
64
65
# File 'lib/codemodels/artifact.rb', line 63

def code
  position_in_host.get_string(host_artifact.code)
end

#embedded?Boolean



67
68
69
# File 'lib/codemodels/artifact.rb', line 67

def embedded?
  true
end

#embedding_levelObject



71
72
73
# File 'lib/codemodels/artifact.rb', line 71

def embedding_level
  @host_artifact.embedding_level+1
end

#final_hostObject



59
60
61
# File 'lib/codemodels/artifact.rb', line 59

def final_host
  host_artifact.final_host
end

#nameObject



75
76
77
# File 'lib/codemodels/artifact.rb', line 75

def name
  '<embedded>'
end

#to_sObject



55
56
57
# File 'lib/codemodels/artifact.rb', line 55

def to_s
  "Embedded in (#{@host_artifact.to_s}) at #{position_in_host}"
end