Class: Wikirate4ruby::Entities::Answer

Inherits:
Card
  • Object
show all
Defined in:
lib/wikirate4ruby/entities/answer.rb

Direct Known Subclasses

RelationshipAnswer

Constant Summary collapse

ATTRIBUTES =
%i[company year value comments record_url metric_name metric_designer sources checked_by].freeze

Constants inherited from Card

Card::CARD_ATTRIBUTES

Instance Method Summary collapse

Methods inherited from Card

#as_json, #raw_json, #to_json, #to_s

Constructor Details

#initialize(answer) ⇒ Answer

Returns a new instance of Answer.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/wikirate4ruby/entities/answer.rb', line 9

def initialize(answer)
  super answer
  raise parsing_error name = "IncompatibleCardType", message = "The input Card is not an Answer but a #{@type}" unless @type.include? 'Answer'

  @metric_name = get_content('name').split('+')[1]
  @metric_designer = get_content('name').split('+')[0]
  @company = get_content 'company'
  @value = get_content 'value'
  @year = get_content 'year'
  @sources = get_array_of 'sources', Source
  @checked_by = get_content 'checked_by'
  @comments = get_content 'comments'
  @record_url = get_content 'record_url'

end