Class: SDL::Types::SDLDescription

Inherits:
SDLSimpleType show all
Includes:
SDLType
Defined in:
lib/sdl/types/sdl_description.rb

Overview

Description values are extended string values with additional conversion functions.

Instance Attribute Summary

Attributes inherited from SDLSimpleType

#parent, #parent_index, #raw_value, #value

Instance Method Summary collapse

Methods included from SDLType

codes, included, #xml_attributes, #xml_value

Methods inherited from SDLSimpleType

#==, #annotated?, #annotations, #initialize, #initialize_value, #to_s

Constructor Details

This class inherits a constructor from SDL::Types::SDLSimpleType

Instance Method Details

#from_nil_class(nilvalue) ⇒ Object



9
10
11
# File 'lib/sdl/types/sdl_description.rb', line 9

def from_nil_class(nilvalue)
  @value = ''
end

#from_nokogiri_xml_element(element) ⇒ Object



13
14
15
# File 'lib/sdl/types/sdl_description.rb', line 13

def from_nokogiri_xml_element(element)
  @value = element.content.squish
end

#to_htmlObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/sdl/types/sdl_description.rb', line 17

def to_html
  case @raw_value
    when Nokogiri::XML::Element
      @raw_value.to_s
    when NilClass
      ''
    when String
      @value
    else
      raise "Cannot convert #{@raw_value.class} to HTML. Please extend SDLDescription#to_html"
  end
end