Class: Dev::TargetProcess::Time

Inherits:
Object
  • Object
show all
Defined in:
lib/firespring_dev_commands/target_process/time.rb

Overview

The class to query time information from Target Process

Constant Summary collapse

RESOURCE_TYPE =

The resource type for the api endpoint

'Time'.freeze
PATH =

The api path for time requests

'/Time'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Time

Returns a new instance of Time.



13
14
15
16
17
18
19
20
21
22
# File 'lib/firespring_dev_commands/target_process/time.rb', line 13

def initialize(data)
  @data = data
  @id = data['Id']
  @type = data['ResourceType']
  @description = data['Description']
  @hours = data['Spent']
  @date = parse_time(data['Date'])
  @story = UserStory.new(data['Assignable']) if data['Assignable']
  @user = User.new(data['User']) if data['User']
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



11
12
13
# File 'lib/firespring_dev_commands/target_process/time.rb', line 11

def data
  @data
end

#dateObject

Returns the value of attribute date.



11
12
13
# File 'lib/firespring_dev_commands/target_process/time.rb', line 11

def date
  @date
end

#descriptionObject

Returns the value of attribute description.



11
12
13
# File 'lib/firespring_dev_commands/target_process/time.rb', line 11

def description
  @description
end

#hoursObject

Returns the value of attribute hours.



11
12
13
# File 'lib/firespring_dev_commands/target_process/time.rb', line 11

def hours
  @hours
end

#idObject

Returns the value of attribute id.



11
12
13
# File 'lib/firespring_dev_commands/target_process/time.rb', line 11

def id
  @id
end

#storyObject

Returns the value of attribute story.



11
12
13
# File 'lib/firespring_dev_commands/target_process/time.rb', line 11

def story
  @story
end

#typeObject

Returns the value of attribute type.



11
12
13
# File 'lib/firespring_dev_commands/target_process/time.rb', line 11

def type
  @type
end

#userObject

Returns the value of attribute user.



11
12
13
# File 'lib/firespring_dev_commands/target_process/time.rb', line 11

def user
  @user
end

Instance Method Details

#parse_time(string) ⇒ Object

Parse the dot net time representation into something that ruby can use



25
26
27
28
29
# File 'lib/firespring_dev_commands/target_process/time.rb', line 25

def parse_time(string)
  return nil unless string && !string.empty?

  ::Time.at(string.slice(6, 10).to_i)
end