Class: Neoneo::Task

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

Overview

Represents a No Kahuna task

At the moment this class is read-only in regards of it’s description. But you can close or reopen a task. This will be improved as soon as possible!

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, description, category, user, project, done = false) ⇒ Task

Returns a new instance of Task.



424
425
426
427
428
429
430
431
432
433
# File 'lib/neoneo.rb', line 424

def initialize(id, description, category, user, project, done = false)
  @id = id
  @description = description
  @category = category
  @user = user
  @project = project
  @done = done
  
  @uncertain = @description =~ /\.{3}$/
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



422
423
424
# File 'lib/neoneo.rb', line 422

def id
  @id
end

#projectObject (readonly)

Returns the value of attribute project.



422
423
424
# File 'lib/neoneo.rb', line 422

def project
  @project
end

#userObject (readonly)

Returns the value of attribute user.



422
423
424
# File 'lib/neoneo.rb', line 422

def user
  @user
end

Instance Method Details

#categoryObject



440
441
442
443
444
# File 'lib/neoneo.rb', line 440

def category
  build_category! unless @category
  
  @category
end

#close!Object



450
451
452
453
454
455
456
457
# File 'lib/neoneo.rb', line 450

def close!
  page = @project.user.agent.get(url)
  form = page.forms.last
  authenticity_token = form.authenticity_token
  
  @project.user.agent.post(url('done'), :authenticity_token => authenticity_token, '_method'.to_sym => 'put')
  @done = true
end

#closed?Boolean

Returns:

  • (Boolean)


470
471
472
# File 'lib/neoneo.rb', line 470

def closed?
  @done
end

#descriptionObject



435
436
437
438
# File 'lib/neoneo.rb', line 435

def description
  build_description! if @uncertain
  @description
end

#reopen!Object



459
460
461
462
463
464
465
466
467
468
# File 'lib/neoneo.rb', line 459

def reopen!
  return unless @done

  page = @project.user.agent.get(url)
  form = page.forms.last
  authenticity_token = form.authenticity_token
  
  @project.user.agent.post(url('not_done'), :authenticity_token => authenticity_token, '_method'.to_sym => 'put')
  @done = false
end

#url(appendix = '') ⇒ Object



446
447
448
# File 'lib/neoneo.rb', line 446

def url(appendix = '')
  @project.url("tasks/#{@id}/#{appendix}")
end