Class: Symgate::Wordlist::Entry

Inherits:
Type
  • Object
show all
Defined in:
lib/symgate/wordlist/entry.rb

Overview

a wordlist entry

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Type

#==, hash_value_with_optional_namespace, #initialize

Constructor Details

This class inherits a constructor from Symgate::Type

Class Method Details

.from_soap(hash) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/symgate/wordlist/entry.rb', line 11

def self.from_soap(hash)
  Symgate::Wordlist::Entry.new(
    word: hash_value_with_optional_namespace(:wl, :word, hash),
    uuid: hash_value_with_optional_namespace(:wl, :uuid, hash),
    priority: hash_value_with_optional_namespace(:wl, :priority, hash).to_i,
    concept_code: hash_value_with_optional_namespace(:wl, :conceptcode, hash),
    symbols: Symgate::Client.savon_array(hash, :symbol,
                                         Symgate::Cml::Symbol),
    custom_graphics: Symgate::Client.savon_array(hash, :customgraphic,
                                                 Symgate::Wordlist::GraphicAttachment),
    last_change: hash_value_with_optional_namespace(:wl, :lastchange, hash)
  )
end

Instance Method Details

#to_sObject



37
38
39
# File 'lib/symgate/wordlist/entry.rb', line 37

def to_s
  "{Entry: #{@word}[#{@priority}]/#{@uuid} (#{@symbols.count}+#{@custom_graphics.count})}"
end

#to_soapObject



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/symgate/wordlist/entry.rb', line 25

def to_soap
  {
    %s(wl:word) => word,
    %s(wl:uuid) => uuid,
    %s(wl:priority) => priority,
    %s(wl:conceptcode) => value_or_nil(concept_code),
    %s(cml:symbol) => @symbols.tryit { map(&:to_soap) },
    %s(wl:customgraphic) => @custom_graphics.tryit { map(&:to_soap) },
    %s(wl:lastchange) => last_change.to_s
  }.delete_if { |_, v| v.nil? }
end