Class: ChangeItem
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#old_value ⇒ Object
Returns the value of attribute old_value.
-
#old_value_id ⇒ Object
readonly
Returns the value of attribute old_value_id.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#time ⇒ Object
Returns the value of attribute time.
-
#value ⇒ Object
Returns the value of attribute value.
-
#value_id ⇒ Object
readonly
Returns the value of attribute value_id.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #artificial? ⇒ Boolean
- #current_status_matches(*status_names_or_ids) ⇒ Object
- #flagged? ⇒ Boolean
-
#initialize(raw:, time:, author:, artificial: false) ⇒ ChangeItem
constructor
A new instance of ChangeItem.
- #inspect ⇒ Object
- #link? ⇒ Boolean
- #old_status_matches(*status_names_or_ids) ⇒ Object
- #priority? ⇒ Boolean
- #resolution? ⇒ Boolean
- #sprint? ⇒ Boolean
- #status? ⇒ Boolean
- #story_points? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(raw:, time:, author:, artificial: false) ⇒ ChangeItem
Returns a new instance of ChangeItem.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/jirametrics/change_item.rb', line 7 def initialize raw:, time:, author:, artificial: false # raw will only ever be nil in a test and in that case field and value should be passed in @raw = raw @time = time raise "Time must be an object of type Time in the correct timezone: #{@time}" if @time.is_a? String @field = field || @raw['field'] @value = value || @raw['toString'] @value_id = @raw['to'].to_i @old_value = @raw['fromString'] @old_value_id = @raw['from']&.to_i @artificial = artificial @author = end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
4 5 6 |
# File 'lib/jirametrics/change_item.rb', line 4 def @author end |
#field ⇒ Object (readonly)
Returns the value of attribute field.
4 5 6 |
# File 'lib/jirametrics/change_item.rb', line 4 def field @field end |
#old_value ⇒ Object
Returns the value of attribute old_value.
5 6 7 |
# File 'lib/jirametrics/change_item.rb', line 5 def old_value @old_value end |
#old_value_id ⇒ Object (readonly)
Returns the value of attribute old_value_id.
4 5 6 |
# File 'lib/jirametrics/change_item.rb', line 4 def old_value_id @old_value_id end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
4 5 6 |
# File 'lib/jirametrics/change_item.rb', line 4 def raw @raw end |
#time ⇒ Object
Returns the value of attribute time.
5 6 7 |
# File 'lib/jirametrics/change_item.rb', line 5 def time @time end |
#value ⇒ Object
Returns the value of attribute value.
5 6 7 |
# File 'lib/jirametrics/change_item.rb', line 5 def value @value end |
#value_id ⇒ Object (readonly)
Returns the value of attribute value_id.
4 5 6 |
# File 'lib/jirametrics/change_item.rb', line 4 def value_id @value_id end |
Instance Method Details
#==(other) ⇒ Object
47 48 49 |
# File 'lib/jirametrics/change_item.rb', line 47 def == other field.eql?(other.field) && value.eql?(other.value) && time.to_s.eql?(other.time.to_s) end |
#artificial? ⇒ Boolean
30 |
# File 'lib/jirametrics/change_item.rb', line 30 def artificial? = @artificial |
#current_status_matches(*status_names_or_ids) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/jirametrics/change_item.rb', line 51 def current_status_matches *status_names_or_ids return false unless status? status_names_or_ids.any? do |name_or_id| case name_or_id when Status name_or_id.id == @value_id when String name_or_id == @value else name_or_id == @value_id end end end |
#flagged? ⇒ Boolean
24 |
# File 'lib/jirametrics/change_item.rb', line 24 def flagged? = (field == 'Flagged') |
#inspect ⇒ Object
45 |
# File 'lib/jirametrics/change_item.rb', line 45 def inspect = to_s |
#link? ⇒ Boolean
36 |
# File 'lib/jirametrics/change_item.rb', line 36 def link? = (field == 'Link') |
#old_status_matches(*status_names_or_ids) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/jirametrics/change_item.rb', line 66 def old_status_matches *status_names_or_ids return false unless status? status_names_or_ids.any? do |name_or_id| case name_or_id when Status name_or_id.id == @old_value_id when String name_or_id == @old_value else name_or_id == @old_value_id end end end |
#priority? ⇒ Boolean
26 |
# File 'lib/jirametrics/change_item.rb', line 26 def priority? = (field == 'priority') |
#resolution? ⇒ Boolean
28 |
# File 'lib/jirametrics/change_item.rb', line 28 def resolution? = (field == 'resolution') |
#sprint? ⇒ Boolean
32 |
# File 'lib/jirametrics/change_item.rb', line 32 def sprint? = (field == 'Sprint') |
#status? ⇒ Boolean
22 |
# File 'lib/jirametrics/change_item.rb', line 22 def status? = (field == 'status') |
#story_points? ⇒ Boolean
34 |
# File 'lib/jirametrics/change_item.rb', line 34 def story_points? = (field == 'Story Points') |
#to_s ⇒ Object
38 39 40 41 42 43 |
# File 'lib/jirametrics/change_item.rb', line 38 def to_s = "ChangeItem(field: #{field.inspect}, value: #{value.inspect}, time: \"#{@time}\"" += ', artificial' if artificial? += ')' end |