# File lib/unitwise/standard/base.rb, line 55 def primary_code attributes["@Code"] end
class Unitwise::Standard::Base
Attributes
attributes[RW]
Public Class Methods
all()
click to toggle source
# File lib/unitwise/standard/base.rb, line 12 def self.all @all ||= read end
hash()
click to toggle source
# File lib/unitwise/standard/base.rb, line 20 def self.hash self.all.map(&:to_hash) end
local_key()
click to toggle source
# File lib/unitwise/standard/base.rb, line 8 def self.local_key remote_key end
new(attributes)
click to toggle source
# File lib/unitwise/standard/base.rb, line 34 def initialize(attributes) @attributes = attributes end
path()
click to toggle source
# File lib/unitwise/standard/base.rb, line 24 def self.path Unitwise.data_file(local_key) end
read()
click to toggle source
# File lib/unitwise/standard/base.rb, line 16 def self.read Unitwise::Standard.hash[remote_key].inject([]){|a,h| a << self.new(h)} end
write()
click to toggle source
# File lib/unitwise/standard/base.rb, line 28 def self.write File.open(path, 'w') do |f| f.write hash.to_yaml end end
Public Instance Methods
names()
click to toggle source
# File lib/unitwise/standard/base.rb, line 38 def names if attributes["name"].respond_to?(:map) attributes["name"].map(&:to_s) else attributes["name"].to_s end end
primary_code()
click to toggle source
secondary_code()
click to toggle source
# File lib/unitwise/standard/base.rb, line 59 def secondary_code attributes["@CODE"] end
symbol()
click to toggle source
# File lib/unitwise/standard/base.rb, line 46 def symbol sym = attributes["printSymbol"] if sym.is_a?(Hash) hash_to_markup(sym) elsif sym sym.to_s end end
to_hash()
click to toggle source
# File lib/unitwise/standard/base.rb, line 63 def to_hash [:names, :symbol, :primary_code, :secondary_code].inject({}) do |h,a| if v = self.send(a) h[a] = v end h end end