Class: Nexpose::Ticket::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/nexpose/ticket.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state, author, created) ⇒ Event

Returns a new instance of Event.



234
235
236
# File 'lib/nexpose/ticket.rb', line 234

def initialize(state, author, created)
  @state, @author, @created = state, author, created
end

Instance Attribute Details

#authorObject (readonly)

The login name of the person responsible for the event.



226
227
228
# File 'lib/nexpose/ticket.rb', line 226

def author
  @author
end

#commentObject

Comment on the ticket event.



232
233
234
# File 'lib/nexpose/ticket.rb', line 232

def comment
  @comment
end

#created_onObject (readonly)

Date and time of the ticket event.



224
225
226
# File 'lib/nexpose/ticket.rb', line 224

def created_on
  @created_on
end

#descriptionObject

Description of the ticket event.



230
231
232
# File 'lib/nexpose/ticket.rb', line 230

def description
  @description
end

#stateObject (readonly)

The status of the ticket at the time the event was recorded.



228
229
230
# File 'lib/nexpose/ticket.rb', line 228

def state
  @state
end

Class Method Details

.parse(xml) ⇒ Object



238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/nexpose/ticket.rb', line 238

def self.parse(xml)
  author = 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, author, created_on)

  comment = REXML::XPath.first(xml, 'Comment')
  event.comment = comment.text if comment

  event.description = desc if desc
  event
end