Class: LangScan::Fragment

Inherits:
Struct
  • Object
show all
Defined in:
lib/langscan/_common.rb,
lib/langscan/_common.rb

Overview

LangScan::Fragment has following variables.

  • type is symbol that denotes Type of the fragment(e.g. :string, :comment,…).

  • text is string that contains text of the fragment.

  • lineno is number of lines where the fragment appears.

  • byteno is number of bytes where the fragment appears.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#beg_bytenoObject Also known as: byteno

Returns the value of attribute beg_byteno

Returns:

  • (Object)

    the current value of beg_byteno



18
19
20
# File 'lib/langscan/_common.rb', line 18

def beg_byteno
  @beg_byteno
end

#beg_linenoObject Also known as: lineno

Returns the value of attribute beg_lineno

Returns:

  • (Object)

    the current value of beg_lineno



18
19
20
# File 'lib/langscan/_common.rb', line 18

def beg_lineno
  @beg_lineno
end

#textObject

Returns the value of attribute text

Returns:

  • (Object)

    the current value of text



18
19
20
# File 'lib/langscan/_common.rb', line 18

def text
  @text
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



18
19
20
# File 'lib/langscan/_common.rb', line 18

def type
  @type
end

Instance Method Details

#end_bytenoObject



39
40
41
# File 'lib/langscan/_common.rb', line 39

def end_byteno
  self.beg_byteno + self.text.length
end

#inspectObject



31
32
33
# File 'lib/langscan/_common.rb', line 31

def inspect
  "\#<#{self.class} #{type} #{text.inspect} #{beg_lineno} (#{beg_byteno})>"
end

#pretty_print(q) ⇒ Object



35
36
37
# File 'lib/langscan/_common.rb', line 35

def pretty_print(q)
  q.text inspect
end