Class: Puppet::Pops::Adapters::SourcePosAdapter
- Inherits:
-
Puppet::Pops::Adaptable::Adapter
- Object
- Puppet::Pops::Adaptable::Adapter
- Puppet::Pops::Adapters::SourcePosAdapter
- Defined in:
- lib/puppet/pops/adapters.rb
Overview
A SourcePosAdapter describes a position relative to an origin. (Typically an OriginAdapter is associated with the root of a model. This origin has a URI to the resource, and a line number. The offset in the SourcePosAdapter is then relative to this origin. (This somewhat complex structure makes it possible to correctly refer to a source position in source that is embedded in some resource; a parser only sees the embedded snippet of source text and does not know where it was embedded).
Instance Attribute Summary collapse
-
#length ⇒ Fixnum
The length (count) of characters of source text representing the adapted object from the origin.
-
#line ⇒ Fixnum
The start line in source starting from 1.
-
#offset ⇒ Fixnum
The (start) offset of source text characters (starting from 0) representing the adapted object.
-
#pos ⇒ Fixnum
The position on the start_line (in characters) starting from 0.
Instance Method Summary collapse
Methods inherited from Puppet::Pops::Adaptable::Adapter
adapt, adapt_new, associate_adapter, clear, create_adapter, get, instance_var_name
Instance Attribute Details
#length ⇒ Fixnum
Returns The length (count) of characters of source text representing the adapted object from the origin. Not including any trailing whitespace.
49 50 51 |
# File 'lib/puppet/pops/adapters.rb', line 49 def length @length end |
#line ⇒ Fixnum
Returns The start line in source starting from 1.
36 37 38 |
# File 'lib/puppet/pops/adapters.rb', line 36 def line @line end |
#offset ⇒ Fixnum
Returns The (start) offset of source text characters (starting from 0) representing the adapted object. Value may be nil.
44 45 46 |
# File 'lib/puppet/pops/adapters.rb', line 44 def offset @offset end |
#pos ⇒ Fixnum
Returns The position on the start_line (in characters) starting from 0.
39 40 41 |
# File 'lib/puppet/pops/adapters.rb', line 39 def pos @pos end |
Instance Method Details
#extract_text_from_string(string) ⇒ Object
51 52 53 |
# File 'lib/puppet/pops/adapters.rb', line 51 def extract_text_from_string(string) string.slice(offset, length) end |