Class: Remi::BusinessRules::DataField
- Inherits:
-
Object
- Object
- Remi::BusinessRules::DataField
- Defined in:
- lib/remi/cucumber/business_rules.rb
Instance Attribute Summary collapse
-
#field_name ⇒ Object
readonly
Returns the value of attribute field_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Instance Method Summary collapse
- #full_name ⇒ Object
-
#initialize(subject, name) ⇒ DataField
constructor
A new instance of DataField.
- #metadata ⇒ Object
- #value ⇒ Object
- #value=(arg) ⇒ Object
- #values ⇒ Object
- #vector ⇒ Object
Constructor Details
#initialize(subject, name) ⇒ DataField
Returns a new instance of DataField.
436 437 438 439 440 |
# File 'lib/remi/cucumber/business_rules.rb', line 436 def initialize(subject, name) @subject = subject @name = name @field_name = name.symbolize(subject.data_obj.field_symbolizer) end |
Instance Attribute Details
#field_name ⇒ Object (readonly)
Returns the value of attribute field_name.
443 444 445 |
# File 'lib/remi/cucumber/business_rules.rb', line 443 def field_name @field_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
442 443 444 |
# File 'lib/remi/cucumber/business_rules.rb', line 442 def name @name end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
444 445 446 |
# File 'lib/remi/cucumber/business_rules.rb', line 444 def subject @subject end |
Instance Method Details
#full_name ⇒ Object
446 447 448 |
# File 'lib/remi/cucumber/business_rules.rb', line 446 def full_name "#{@subject.name}: #{@name}" end |
#metadata ⇒ Object
450 451 452 |
# File 'lib/remi/cucumber/business_rules.rb', line 450 def @subject.data_obj.fields[@field_name] end |
#value ⇒ Object
458 459 460 461 462 |
# File 'lib/remi/cucumber/business_rules.rb', line 458 def value v = vector.to_a.uniq raise "Multiple unique values found in subject data for field #{@field_name}" if v.size > 1 v.first end |
#value=(arg) ⇒ Object
468 469 470 |
# File 'lib/remi/cucumber/business_rules.rb', line 468 def value=(arg) vector.recode! { |v| arg } end |
#values ⇒ Object
464 465 466 |
# File 'lib/remi/cucumber/business_rules.rb', line 464 def values vector.to_a.map(&:to_s) end |
#vector ⇒ Object
454 455 456 |
# File 'lib/remi/cucumber/business_rules.rb', line 454 def vector @subject.data_obj.df[@field_name] end |