Class: Interscript::Node::Item::CaptureGroup

Inherits:
Interscript::Node::Item show all
Defined in:
lib/interscript/node/item/capture.rb,
lib/interscript/visualize/nodes.rb

Overview

(…)

Instance Attribute Summary collapse

Attributes inherited from Interscript::Node::Item

#item

Instance Method Summary collapse

Methods inherited from Interscript::Node::Item

#+, try_convert

Constructor Details

#initialize(data) ⇒ CaptureGroup

Returns a new instance of CaptureGroup.



5
6
7
8
# File 'lib/interscript/node/item/capture.rb', line 5

def initialize(data)
  data = Interscript::Node::Item.try_convert(data)
  @data = data
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



3
4
5
# File 'lib/interscript/node/item/capture.rb', line 3

def data
  @data
end

Instance Method Details

#==(other) ⇒ Object



26
27
28
# File 'lib/interscript/node/item/capture.rb', line 26

def ==(other)
  super && self.data == other.data
end

#downcaseObject



18
# File 'lib/interscript/node/item/capture.rb', line 18

def downcase; self.dup.tap { |i| i.data = i.data.downcase }; end

#first_stringObject



10
11
12
# File 'lib/interscript/node/item/capture.rb', line 10

def first_string
  data.first_string
end

#inspectObject



30
31
32
# File 'lib/interscript/node/item/capture.rb', line 30

def inspect
  "capture(#{@data.inspect})"
end

#nth_stringObject



14
15
16
# File 'lib/interscript/node/item/capture.rb', line 14

def nth_string
  data.nth_string
end

#to_hashObject



21
22
23
24
# File 'lib/interscript/node/item/capture.rb', line 21

def to_hash
  { :class => self.class.to_s,
    :data => self.data.to_hash }
end

#to_html(doc) ⇒ Object



42
43
44
45
46
# File 'lib/interscript/visualize/nodes.rb', line 42

def to_html(doc)
  "<nobr>capture group (</nobr>" +
    data.to_html(doc) +
  ")"
end

#upcaseObject



19
# File 'lib/interscript/node/item/capture.rb', line 19

def upcase; self.dup.tap { |i| i.data = i.data.upcase }; end