Class: Terraspace::Terraform::Tfc::Runs::ItemPresenter
- Inherits:
-
Object
- Object
- Terraspace::Terraform::Tfc::Runs::ItemPresenter
show all
- Defined in:
- lib/terraspace/terraform/tfc/runs/item_presenter.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ItemPresenter.
4
5
6
7
8
|
# File 'lib/terraspace/terraform/tfc/runs/item_presenter.rb', line 4
def initialize(raw)
@raw = raw @id = raw['id']
@attrs = raw['attributes']
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
10
11
12
13
14
15
16
17
|
# File 'lib/terraspace/terraform/tfc/runs/item_presenter.rb', line 10
def method_missing(name, *args, &block)
attrs = @attrs.transform_keys { |k| k.gsub('-','_').to_sym }
if attrs.key?(name)
attrs[name]
else
super
end
end
|
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
3
4
5
|
# File 'lib/terraspace/terraform/tfc/runs/item_presenter.rb', line 3
def id
@id
end
|
Instance Method Details
#created_at ⇒ Object
29
30
31
|
# File 'lib/terraspace/terraform/tfc/runs/item_presenter.rb', line 29
def created_at
pretty_time(@attrs['created-at'])
end
|
#message ⇒ Object
19
20
21
22
23
24
25
26
27
|
# File 'lib/terraspace/terraform/tfc/runs/item_presenter.rb', line 19
def message
max = 25
message = @attrs['message']
if message.size >= max
message[0..max] + "..."
else
message
end
end
|
#pretty_time(text) ⇒ Object
33
34
35
|
# File 'lib/terraspace/terraform/tfc/runs/item_presenter.rb', line 33
def pretty_time(text)
text.sub(/\..*/,'')
end
|