Class: DTK::Client::Violation::Attribute
- Inherits:
-
Object
- Object
- DTK::Client::Violation::Attribute
- Defined in:
- lib/violation/attribute.rb
Overview
represents a component, node, or assembly attribute
Instance Method Summary collapse
-
#illegal_value?(value) ⇒ Boolean
Returns error message if an error.
-
#initialize(attribute_hash) ⇒ Attribute
constructor
A new instance of Attribute.
- #prompt_user_for_value ⇒ Object
- #set_attribute(service_id, value) ⇒ Object
Constructor Details
#initialize(attribute_hash) ⇒ Attribute
Returns a new instance of Attribute.
22 23 24 25 26 27 28 29 |
# File 'lib/violation/attribute.rb', line 22 def initialize(attribute_hash) # ref is the only key that is guarenteed to be present @ref = attribute_hash['ref'] @datatype = attribute_hash['datatype'] @hidden = attribute_hash['hidden'] @legal_values = attribute_hash['legal_values'] @fix_text = attribute_hash['fix_text'] end |
Instance Method Details
#illegal_value?(value) ⇒ Boolean
Returns error message if an error
36 37 38 |
# File 'lib/violation/attribute.rb', line 36 def illegal_value?(value) value_does_not_match_datatype?(value) or value_not_legal_type?(value) end |
#prompt_user_for_value ⇒ Object
31 32 33 |
# File 'lib/violation/attribute.rb', line 31 def prompt_user_for_value Shell::InteractiveWizard.prompt_user_for_value(fix_text) end |
#set_attribute(service_id, value) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/violation/attribute.rb', line 40 def set_attribute(service_id, value) post_body = { :assembly_id => service_id, :pattern => @ref, :value => value } response = Session.post('assembly/set_attributes', post_body) response.ok? ? Fix::Result.ok : Fix::Result.error end |