Class: PatternRuby::Entity

Inherits:
Object
  • Object
show all
Defined in:
lib/pattern_ruby/entity.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, type: :string, value: nil, raw: nil, span: nil) ⇒ Entity

Returns a new instance of Entity.



5
6
7
8
9
10
11
# File 'lib/pattern_ruby/entity.rb', line 5

def initialize(name:, type: :string, value: nil, raw: nil, span: nil)
  @name = name.to_sym
  @type = type.to_sym
  @value = value
  @raw = raw
  @span = span
end

Instance Attribute Details

#name ⇒ Object (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/pattern_ruby/entity.rb', line 3

def name
  @name
end

#raw ⇒ Object (readonly)

Returns the value of attribute raw.



3
4
5
# File 'lib/pattern_ruby/entity.rb', line 3

def raw
  @raw
end

#span ⇒ Object (readonly)

Returns the value of attribute span.



3
4
5
# File 'lib/pattern_ruby/entity.rb', line 3

def span
  @span
end

#type ⇒ Object (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/pattern_ruby/entity.rb', line 3

def type
  @type
end

#value ⇒ Object (readonly)

Returns the value of attribute value.



3
4
5
# File 'lib/pattern_ruby/entity.rb', line 3

def value
  @value
end

Instance Method Details

#to_h ⇒ Object



13
14
15
# File 'lib/pattern_ruby/entity.rb', line 13

def to_h
  { name: @name, type: @type, value: @value, raw: @raw }
end