Class: Versionub::Type::Instance

Inherits:
Object
  • Object
show all
Defined in:
lib/versionub/type.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, text, data) ⇒ Instance

Returns a new instance of Instance.



28
29
30
31
32
# File 'lib/versionub/type.rb', line 28

def initialize (type, text, data)
  @type = type
  @text = text
  @data = data
end

Class Attribute Details

.parserObject

Returns the value of attribute parser.



43
44
45
# File 'lib/versionub/type.rb', line 43

def parser
  @parser
end

.transformerObject

Returns the value of attribute transformer.



43
44
45
# File 'lib/versionub/type.rb', line 43

def transformer
  @transformer
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



26
27
28
# File 'lib/versionub/type.rb', line 26

def type
  @type
end

Class Method Details

.parse(&block) ⇒ Object



45
46
47
48
49
50
51
52
# File 'lib/versionub/type.rb', line 45

def parse (&block)
  if block
    @parser = Class.new(Parslet::Parser)
    @parser.class_eval(&block)
  end

  @parser
end

.transform(&block) ⇒ Object



54
55
56
57
58
59
60
61
# File 'lib/versionub/type.rb', line 54

def transform (&block)
  if block
    @transformer = Class.new(Parslet::Transform)
    @transformer.class_eval(&block)
  end

  @transformer
end

Instance Method Details

#to_hashObject



34
35
36
# File 'lib/versionub/type.rb', line 34

def to_hash
  @data.clone
end

#to_sObject



38
39
40
# File 'lib/versionub/type.rb', line 38

def to_s
  @text
end