Class: Ringo::StoryCard
- Inherits:
-
Object
- Object
- Ringo::StoryCard
- Defined in:
- lib/ringo/story_card.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, number, properties) ⇒ StoryCard
constructor
A new instance of StoryCard.
- #status ⇒ Object
- #to_emit(max = 1000) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(name, number, properties) ⇒ StoryCard
Returns a new instance of StoryCard.
29 30 31 32 33 |
# File 'lib/ringo/story_card.rb', line 29 def initialize name, number, properties @name = name @number = number @properties = properties end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
27 28 29 |
# File 'lib/ringo/story_card.rb', line 27 def name @name end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
27 28 29 |
# File 'lib/ringo/story_card.rb', line 27 def number @number end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
27 28 29 |
# File 'lib/ringo/story_card.rb', line 27 def properties @properties end |
Class Method Details
.from_card(card_result) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ringo/story_card.rb', line 15 def self.from_card card_result card_node = card_result.css('card') properties = card_node.css('property').map do |property_node| Property.from_result property_node end name = card_node.at_css('name').text if card_node.at_css('name') number = card_node.at_css('number').text if card_node.at_css('number') StoryCard.new name, number, properties end |
.from_result(result) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/ringo/story_card.rb', line 3 def self.from_result result result.css('card').map do |node| properties = node.css('property').map do |property_node| Property.from_result property_node end StoryCard.new node.at_css('name').text, node.at_css('number').text, properties end end |
Instance Method Details
#status ⇒ Object
35 36 37 |
# File 'lib/ringo/story_card.rb', line 35 def status properties.detect { |property| property.name == 'Status' }.value end |
#to_emit(max = 1000) ⇒ Object
39 40 41 |
# File 'lib/ringo/story_card.rb', line 39 def to_emit(max=1000) "##{number} - #{name}"[0..max] end |
#to_hash ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/ringo/story_card.rb', line 43 def to_hash { name: name[0..30], number: number, status: status } end |