Class: Nexpose::Ticket::Event
- Inherits:
-
Object
- Object
- Nexpose::Ticket::Event
- Defined in:
- lib/nexpose/ticket.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
The login name of the person responsible for the event.
-
#comment ⇒ Object
Comment on the ticket event.
-
#created_on ⇒ Object
readonly
Date and time of the ticket event.
-
#description ⇒ Object
Description of the ticket event.
-
#state ⇒ Object
readonly
The status of the ticket at the time the event was recorded.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(state, author, created) ⇒ Event
constructor
A new instance of Event.
Constructor Details
#initialize(state, author, created) ⇒ Event
Returns a new instance of Event.
235 236 237 238 239 |
# File 'lib/nexpose/ticket.rb', line 235 def initialize(state, , created) @state = state @author = @created = created end |
Instance Attribute Details
#author ⇒ Object (readonly)
The login name of the person responsible for the event.
227 228 229 |
# File 'lib/nexpose/ticket.rb', line 227 def @author end |
#comment ⇒ Object
Comment on the ticket event.
233 234 235 |
# File 'lib/nexpose/ticket.rb', line 233 def comment @comment end |
#created_on ⇒ Object (readonly)
Date and time of the ticket event.
225 226 227 |
# File 'lib/nexpose/ticket.rb', line 225 def created_on @created_on end |
#description ⇒ Object
Description of the ticket event.
231 232 233 |
# File 'lib/nexpose/ticket.rb', line 231 def description @description end |
#state ⇒ Object (readonly)
The status of the ticket at the time the event was recorded.
229 230 231 |
# File 'lib/nexpose/ticket.rb', line 229 def state @state end |
Class Method Details
.parse(xml) ⇒ Object
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'lib/nexpose/ticket.rb', line 241 def self.parse(xml) = xml.attributes['author'] created_on = DateTime.parse(xml.attributes['created-on']).to_time created_on -= created_on.gmt_offset event = REXML::XPath.first(xml, 'Event') lookup = Ticket::State.constants.reduce({}) { |a, e| a[Ticket::State.const_get(e)] = e; a } state = lookup[event.attributes['state']] desc = event.text event = new(state, , created_on) comment = REXML::XPath.first(xml, 'Comment') event.comment = comment.text if comment event.description = desc if desc event end |