Class: Licensario::License
Instance Attribute Summary collapse
-
#expiration_date_utc ⇒ Object
Returns the value of attribute expiration_date_utc.
-
#id ⇒ Object
Returns the value of attribute id.
-
#included_features ⇒ Object
Returns the value of attribute included_features.
-
#included_resources ⇒ Object
Returns the value of attribute included_resources.
-
#is_trial ⇒ Object
Returns the value of attribute is_trial.
-
#issue_date_utc ⇒ Object
Returns the value of attribute issue_date_utc.
-
#payment_plan_id ⇒ Object
Returns the value of attribute payment_plan_id.
-
#user_id ⇒ Object
Returns the value of attribute user_id.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ License
constructor
A new instance of License.
- #to_s ⇒ Object
Methods inherited from Base
api, date_format, establish_connection
Constructor Details
#initialize(attributes = {}) ⇒ License
Returns a new instance of License.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/licensario/license.rb', line 7 def initialize(attributes = {}) if attributes[:xml_node] or attributes[:xml] xml_node = attributes[:xml_node] ? attributes[:xml_node] : Nokogiri::XML(attributes[:xml]).xpath("//licenseCertificate")[0] xml_attrs = xml_node.attributes { id: 'licenseId', user_id: 'userId', payment_plan_id: 'paymentPlanId', issue_date_utc: 'issueDateUTC', expiration_date_utc: 'expirationDateUTC', is_trial: 'is_trial' }.each do |k,v| attributes[k] = xml_attrs[v] ? xml_attrs[v].value : nil end attributes[:included_resources] = [] xml_node.xpath("//resources/resource").each do |node| resource = Licensario::LicensedResource.new(xml_node: node) attributes[:included_resources] << resource end attributes[:included_features] = [] xml_node.xpath("//features/feature").each do |node| feature = Licensario::LicensedFeature.new(xml_node: node) attributes[:included_features] << feature end attributes.delete(:xml_node) attributes.delete(:xml) end attributes[:is_trial] = 'false' if !attributes.has_key?(:is_trial) super(attributes) end |
Instance Attribute Details
#expiration_date_utc ⇒ Object
Returns the value of attribute expiration_date_utc.
5 6 7 |
# File 'lib/licensario/license.rb', line 5 def expiration_date_utc @expiration_date_utc end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/licensario/license.rb', line 5 def id @id end |
#included_features ⇒ Object
Returns the value of attribute included_features.
5 6 7 |
# File 'lib/licensario/license.rb', line 5 def included_features @included_features end |
#included_resources ⇒ Object
Returns the value of attribute included_resources.
5 6 7 |
# File 'lib/licensario/license.rb', line 5 def included_resources @included_resources end |
#is_trial ⇒ Object
Returns the value of attribute is_trial.
5 6 7 |
# File 'lib/licensario/license.rb', line 5 def is_trial @is_trial end |
#issue_date_utc ⇒ Object
Returns the value of attribute issue_date_utc.
5 6 7 |
# File 'lib/licensario/license.rb', line 5 def issue_date_utc @issue_date_utc end |
#payment_plan_id ⇒ Object
Returns the value of attribute payment_plan_id.
5 6 7 |
# File 'lib/licensario/license.rb', line 5 def payment_plan_id @payment_plan_id end |
#user_id ⇒ Object
Returns the value of attribute user_id.
5 6 7 |
# File 'lib/licensario/license.rb', line 5 def user_id @user_id end |
Instance Method Details
#to_s ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/licensario/license.rb', line 48 def to_s s = %Q{} s += "licenseId: #{id}\n" s += "isTrial: #{is_trial}\n" s += "userId: #{user_id}\n" s += "issued(UTC): #{issue_date_utc}\n" s += "expires(UTC): #{expiration_date_utc}\n" s += "includedFeatures: #{included_features}\n" s += "includedResources: #{included_resources}\n" return s end |