Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

68 lines (66 sloc) 1.964 kb
# -*- ruby -*-
#--
# Copyright 2008 Danny Coates, Ashkan Farhadtouski
# All rights reserved.
# See LICENSE for permissions.
#++
# AUTOGENERATED class
module HealthVault
module WCData
<%- modules.each do |m| -%>
module <%= hv_classify(m) %>
<%- end -%>
<%= "##{class_name} is a #{children['base'].to_s}" %>
class <%= class_name %> < SimpleType
<% children.each do |name, target| %>
<% if name == 'enumeration' %>
<% target.each do |enum| %>
def self.<%= enum.empty? ? 'empty' : enum.to_s.downcase.strip.gsub(' ', '_').underscore %>
return '<%= enum.to_s %>'
end
<% end %>
def self.enum
return ['<%= target.join("','") %>']
end
<% elsif name != 'base' %>
<%= "##{name} = #{target.to_s}" %>
def <%= name %>(value)
<% case name
when 'minExclusive' %>
return value > <%= target %>
<% when 'minInclusive' %>
return value >= <%= target %>
<% when 'maxExclusive' %>
return value < <%= target %>
<% when 'minInclusive' %>
return value <= <%= target %>
<% when 'length' %>
return value.length == <%= target %>
<% when 'minLength' %>
return value.length > <%= target %>
<% when 'maxLength' %>
return value.length < <%= target %>
<% else %>
return true
<% end %>
end
<% end %>
<% end %>
def self.valid?(value)
result = true
<% children.each do |name, target| %>
<% case name
when 'enumeration'%>
result = result && self.enum.include?(value)
<% when 'base' %>
<% else %>
result = result && self.<%= name %>(value)
<% end %>
<% end %>
return result
end
end
<%modules.length.times do %>end
<% end %>
end
end
Jump to Line
Something went wrong with that request. Please try again.