Class: MESH::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/MESH/entry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(heading, entry_text) ⇒ Entry

Returns a new instance of Entry.



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
# File 'lib/MESH/entry.rb', line 7

def initialize(heading, entry_text)
  @heading = heading
  @semantic_types = []
  parts = entry_text.split('|')
  if entry_text.include? '|'
    key = parts.pop
    parts.each_with_index do |part, i|
      case key[i]
        when 'a' # the term itself
          @term = part
        when 'b' # semantic type*
          @semantic_types << MESH::SemanticTypes[part]
        when 'c' # lexical type*
          @lexical_type = MESH::LexicalTypes[part]
        when 'd' # semantic relation*
          @semantic_relationship = MESH::SemanticRelationshipTypes[part]
        when 'e' # thesaurus id
        when 'f' # date
        when 's' # sort version
        when 'v' # entry version
      end
    end
  else
    @term = entry_text
  end
end

Instance Attribute Details

#headingObject

Returns the value of attribute heading.



5
6
7
# File 'lib/MESH/entry.rb', line 5

def heading
  @heading
end

#lexical_typeObject

Returns the value of attribute lexical_type.



5
6
7
# File 'lib/MESH/entry.rb', line 5

def lexical_type
  @lexical_type
end

#semantic_relationshipObject

Returns the value of attribute semantic_relationship.



5
6
7
# File 'lib/MESH/entry.rb', line 5

def semantic_relationship
  @semantic_relationship
end

#semantic_typesObject

Returns the value of attribute semantic_types.



5
6
7
# File 'lib/MESH/entry.rb', line 5

def semantic_types
  @semantic_types
end

#termObject

Returns the value of attribute term.



5
6
7
# File 'lib/MESH/entry.rb', line 5

def term
  @term
end