class ZanoxPublisher::Policy
Attributes
id[R]
name[R]
Public Class Methods
fetch(data = nil)
click to toggle source
# File lib/zanox_publisher/policy.rb, line 4 def fetch(data = nil) # To support API of picking categories of hash with [] notation return nil if data.nil? # Try to fetch policy else make data it an array policies = data.fetch('policy', nil) policies = [data] if policies.nil? policies = [policies] if policies.is_a? Hash # Build the return value retval = [] policies.each do |policy| retval << Policy.new(policy) end retval end
new(data = {})
click to toggle source
# File lib/zanox_publisher/policy.rb, line 26 def initialize(data = {}) @id = data.fetch('@id').to_i @name = data.fetch('$', nil) end
Public Instance Methods
to_i()
click to toggle source
Returns the policy ID as integer representation
@return [Integer]
# File lib/zanox_publisher/policy.rb, line 38 def to_i @id end
to_s()
click to toggle source
# File lib/zanox_publisher/policy.rb, line 31 def to_s @name end