Class: Glossarist::Designation::Expression

Inherits:
Base
  • Object
show all
Defined in:
lib/glossarist/designation/expression.rb

Direct Known Subclasses

Abbreviation

Instance Attribute Summary collapse

Attributes inherited from Base

#designation, #geographical_area

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utilities::Enum

extended, included

Methods inherited from Model

#initialize, new, #set_attribute

Constructor Details

This class inherits a constructor from Glossarist::Model

Instance Attribute Details

#grammar_infoArray<GrammarInfo>

List of grammar info.

Returns:



13
14
15
# File 'lib/glossarist/designation/expression.rb', line 13

def grammar_info
  @grammar_info
end

#prefixObject

Returns the value of attribute prefix.



8
9
10
# File 'lib/glossarist/designation/expression.rb', line 8

def prefix
  @prefix
end

#usage_infoObject

Returns the value of attribute usage_info.



9
10
11
# File 'lib/glossarist/designation/expression.rb', line 9

def usage_info
  @usage_info
end

Class Method Details

.from_h(hash) ⇒ Object

TODO:

Added to cater for current iev-data implementation, might be removed in the future.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/glossarist/designation/expression.rb', line 21

def self.from_h(hash)
  gender = hash.delete("gender") || hash.delete(:gender)
  number = hash.delete("plurality") || hash.delete(:plurality)
  part_of_speech = hash.delete("part_of_speech") || hash.delete(:part_of_speech)

  if gender || number || part_of_speech
    hash["grammar_info"] = [{
      "gender" => gender,
      "number" => number,
      part_of_speech => part_of_speech,
    }.compact]
  end

  super
end

Instance Method Details

#to_hObject



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/glossarist/designation/expression.rb', line 37

def to_h
  {
    "type" => "expression",
    "prefix" => prefix,
    "normative_status" => normative_status,
    "usage_info" => usage_info,
    "designation" => designation,
    "geographical_area" => geographical_area,
    "grammar_info" => grammar_info&.map(&:to_h),
  }.compact
end