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

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#rawObject (readonly)

Returns the value of attribute raw.



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

def raw
  @raw
end

#spanObject (readonly)

Returns the value of attribute span.



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

def span
  @span
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

#valueObject (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_hObject



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

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