Class: RegexRestrictedString

Inherits:
Object
  • Object
show all
Includes:
SerializableToXml
Defined in:
lib/voruby/misc.rb

Overview

Regex-restricted string

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializableToXml

#element

Constructor Details

#initialize(s) ⇒ RegexRestrictedString

Returns a new instance of RegexRestrictedString.



323
324
325
# File 'lib/voruby/misc.rb', line 323

def initialize(s)
  self.value = s
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



319
320
321
# File 'lib/voruby/misc.rb', line 319

def value
  @value
end

Class Method Details

.from_xml(xml) ⇒ Object



347
348
349
350
# File 'lib/voruby/misc.rb', line 347

def self.from_xml(xml)
  root = element_from(xml)
  self.new(root.text)
end

Instance Method Details

#==(s) ⇒ Object



335
336
337
# File 'lib/voruby/misc.rb', line 335

def ==(s)
  self.value == s.value
end

#regexObject



327
# File 'lib/voruby/misc.rb', line 327

def regex; /.*/ end

#to_sObject



339
# File 'lib/voruby/misc.rb', line 339

def to_s; self.value.to_s end

#to_xml(name = nil, ns = nil) ⇒ Object



341
342
343
344
345
# File 'lib/voruby/misc.rb', line 341

def to_xml(name=nil, ns=nil)
  el = element(name, ns)
  el.text = self.value
  el
end