class UcodeIssuer::UcodeIssuer

Your code goes here…

Public Class Methods

format(f,t) click to toggle source
# File lib/ucodeIssuer.rb, line 16
def self.format(f,t)
  YAML.dump({
    'from_ucode' => f,
    'to_ucode'   => t,
    'now_ucode'  => f
  },open(@@yaml_file,'w'))
end
getCurrent() click to toggle source
# File lib/ucodeIssuer.rb, line 41
def self.getCurrent
  @@yaml_store.transaction do |hash|
    return hash['now_ucode']
  end
end
issue() click to toggle source
# File lib/ucodeIssuer.rb, line 47
def self.issue
  issueUcode = nil
  @@yaml_store.transaction do |hash|
    issueUcode = hash['now_ucode']
    hash['now_ucode'] = sprintf("%#034X",(hash['now_ucode'].hex + 1)).gsub(/^0X/,"")
  end
  return issueUcode
end
setReagion(f,t) click to toggle source
# File lib/ucodeIssuer.rb, line 24
def self.setReagion(f,t)
  @@yaml = YAML.load_file(@@yaml_file)
  initial = {
    'from_ucode' => f,
    'to_ucode'   => t
  }
  initial['now_ucode']  = f if @@yaml['now_ucode'].nil?
  
  store = YAML::Store.new(@@yaml_file)
  ## データの読み出しと格納
  store.transaction do |hash|
    @@yaml.each do |k,v|
      hash[k] = v
    end
  end
end

Public Instance Methods

init() click to toggle source
# File lib/ucodeIssuer.rb, line 12
def init
  @@yaml_store = YAML::Store.new(@@yaml_file)
end