Class: ActiveApi::SimpleType
- Inherits:
-
Object
- Object
- ActiveApi::SimpleType
- Includes:
- Builder
- Defined in:
- lib/active_api/simple_type.rb
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
- #append(hash) ⇒ Object
-
#initialize(text, options) ⇒ SimpleType
constructor
A new instance of SimpleType.
Methods included from Builder
Constructor Details
#initialize(text, options) ⇒ SimpleType
Returns a new instance of SimpleType.
81 82 83 84 85 |
# File 'lib/active_api/simple_type.rb', line 81 def initialize(text, ) @text = text @node = [:node] @format = [:format] end |
Instance Attribute Details
#format ⇒ Object (readonly)
Returns the value of attribute format.
79 80 81 |
# File 'lib/active_api/simple_type.rb', line 79 def format @format end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
79 80 81 |
# File 'lib/active_api/simple_type.rb', line 79 def node @node end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
79 80 81 |
# File 'lib/active_api/simple_type.rb', line 79 def text @text end |
Class Method Details
.default_format_proc ⇒ Object
63 64 65 |
# File 'lib/active_api/simple_type.rb', line 63 def default_format_proc proc { |value| value } end |
.format_procs ⇒ Object
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/active_api/simple_type.rb', line 67 def format_procs { :normalized_string => proc {|value| value }, :token => proc {|value| value }, :date_time => proc {|value| value.strftime("%Y-%m-%dT%H:%M:%S%Z") }, :time => proc {|value| value.strftime("%H:%M:%S%Z") }, :date => proc {|value| value.strftime("%Y-%m-%d") }, :any_uri => proc {|value| URI.escape(value) } } end |
.formats ⇒ Object
6 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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/active_api/simple_type.rb', line 6 def formats standard_names = [ :base64Binary, :boolean, :date, :dateTime, :dateTimeStamp, :decimal, :integer, :long, :int, :short, :byte, :nonNegativeInteger, :positiveInteger, :unsignedLong, :unsignedInt, :unsignedShort, :unsignedByte, :nonPositiveInteger, :negativeInteger, :double, :duration, :dayTimeDuration, :yearMonthDuration, :float, :gDay, :gMonth, :gMonthDay, :gYear, :gYearMonth, :hexBinary, :precisionDecimal, :string, :normalizedString, :token, :language, :time ].map do |format| {format.to_s.underscore.to_sym => format} end custom_names = [ {:any_uri => :anyURI}, {:notation => :NOTATION}, {:qname => :QName}, {:name => :Name}, {:nc_name => :NCName}, {:entity => :ENTITY}, {:id => :ID}, {:idref => :IDREF}, {:nmtoken => :NMTOKEN}, ] standard_names + custom_names end |
Instance Method Details
#append(hash) ⇒ Object
87 88 89 |
# File 'lib/active_api/simple_type.rb', line 87 def append(hash) hash[node] = formatted_text end |