Class: Syobocal::Comment::Person

Inherits:
Object
  • Object
show all
Defined in:
lib/syobocal/comment/person.rb

Constant Summary collapse

PERSON_SEPARATOR =
""
ENCODED_SEPARATOR =
"\t"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, note) ⇒ Person

Returns a new instance of Person.



9
10
11
# File 'lib/syobocal/comment/person.rb', line 9

def initialize(name, note)
  @name, @note = name, note
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/syobocal/comment/person.rb', line 7

def name
  @name
end

#noteObject (readonly)

Returns the value of attribute note.



7
8
9
# File 'lib/syobocal/comment/person.rb', line 7

def note
  @note
end

Class Method Details

.parse(str) ⇒ Object



17
18
19
20
21
# File 'lib/syobocal/comment/person.rb', line 17

def self.parse(str)
  _, name, note = *(str.match(/\A([^\(\)]+?)(?:\((.*?)\))?\Z/).to_a)

  Person.new(name, note)
end

Instance Method Details

#==(other) ⇒ Object



13
14
15
# File 'lib/syobocal/comment/person.rb', line 13

def ==(other)
  other.instance_of?(self.class) && other.name == name && other.note == note
end