Class: InciScore::Response
- Inherits:
-
Object
- Object
- InciScore::Response
- Defined in:
- lib/inci_score/response.rb
Instance Attribute Summary collapse
-
#components ⇒ Object
readonly
Returns the value of attribute components.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
-
#unrecognized ⇒ Object
readonly
Returns the value of attribute unrecognized.
-
#valid ⇒ Object
readonly
Returns the value of attribute valid.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Response
constructor
A new instance of Response.
- #to_json ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Response
Returns a new instance of Response.
7 8 9 10 11 12 |
# File 'lib/inci_score/response.rb', line 7 def initialize( = {}) @components = .fetch(:components) { [] } @score = .fetch(:score) { 0.0 } @unrecognized = .fetch(:unrecognized) { [] } @valid = .fetch(:valid) { false } end |
Instance Attribute Details
#components ⇒ Object (readonly)
Returns the value of attribute components.
5 6 7 |
# File 'lib/inci_score/response.rb', line 5 def components @components end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
5 6 7 |
# File 'lib/inci_score/response.rb', line 5 def score @score end |
#unrecognized ⇒ Object (readonly)
Returns the value of attribute unrecognized.
5 6 7 |
# File 'lib/inci_score/response.rb', line 5 def unrecognized @unrecognized end |
#valid ⇒ Object (readonly)
Returns the value of attribute valid.
5 6 7 |
# File 'lib/inci_score/response.rb', line 5 def valid @valid end |
Instance Method Details
#to_json ⇒ Object
14 15 16 |
# File 'lib/inci_score/response.rb', line 14 def to_json { components: @components, unrecognized: @unrecognized, score: @score, valid: @valid }.to_json end |
#to_s ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/inci_score/response.rb', line 18 def to_s %Q{ TOTAL SCORE: \t#{@score} VALID STATE: \t#{@valid} COMPONENTS: #{@components.map { |c| "\t#{c}" }.join("\n")} UNRECOGNIZED: #{@unrecognized.map { |c| "\t#{c}" }.join("\n")} } end |