Class: Tjplurk::Robot::Topic
- Inherits:
-
Object
- Object
- Tjplurk::Robot::Topic
- Defined in:
- lib/tjplurk/robot/topic.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#pattern ⇒ Object
Returns the value of attribute pattern.
-
#responses ⇒ Object
Returns the value of attribute responses.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(**params) ⇒ Topic
constructor
A new instance of Topic.
Constructor Details
#initialize(**params) ⇒ Topic
Returns a new instance of Topic.
18 19 20 |
# File 'lib/tjplurk/robot/topic.rb', line 18 def initialize(**params) params.each{|key, value| send("#{key}=", value)} end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/tjplurk/robot/topic.rb', line 7 def name @name end |
#pattern ⇒ Object
Returns the value of attribute pattern.
7 8 9 |
# File 'lib/tjplurk/robot/topic.rb', line 7 def pattern @pattern end |
#responses ⇒ Object
Returns the value of attribute responses.
7 8 9 |
# File 'lib/tjplurk/robot/topic.rb', line 7 def responses @responses end |
Class Method Details
.load(yaml) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/tjplurk/robot/topic.rb', line 9 def load yaml YAML.load(yaml).map do |attributes| topic = self.new name: attributes['name'], pattern: attributes['pattern'] topic.responses = attributes['responses'].map{|res| Response.new(topic: topic, content: res)} topic end end |