class Linguistics::Latin::Verb::LatinVerb

Public Class Methods

json_create(o) click to toggle source
# File lib/latinverb_serialization/json.rb, line 5
def self.json_create(o)
  new(o)
end

Public Instance Methods

to_h()
Alias for: to_hash
to_hash() click to toggle source
# File lib/latinverb_serialization/hash.rb, line 5
def to_hash
  TENSE_BLOCK_NAMES.each_with_object(base_structure) do |tense_block_identifier, memo|
    memo[ts = (tense_block_identifier.to_sym)] = self.send(ts)
  end
end
Also aliased as: to_h
to_json(*a) click to toggle source
# File lib/latinverb_serialization/json.rb, line 9
def to_json(*a)
  json_hash = {'json_class' => self.class.name}

  # In the case that we're working with a regular verb, the only thing
  # we need to save is the original string, since everything can be
  # re-derived from it easily.
  unless self.irregular?
    # While this single string is sufficient to freeze and revivifty
    # the verb, it means that the JSON structure is rather vacuous.
    # Given this, the hash is enriched so that the JSON data is
    # useful.  Nevertheless, in the revivification process, only
    # 'orig_string' is used.
    %w{original_string classification stem}.each do |k|
      json_hash[k] = self.send k.to_sym
    end
    json_hash['tense_list' ]  = {}
    LatinVerb::TENSE_BLOCK_NAMES.each do |t|
      json_hash['tense_list'][t.to_s] = self.querent.send t.to_sym
    end
    json_hash['irregular']    = irregular?
    return json_hash.to_json(*a)
  end
end
to_y()
Alias for: to_yaml
to_yaml() click to toggle source
# File lib/latinverb_serialization/yaml.rb, line 5
def to_yaml
  to_hash.to_yaml
end
Also aliased as: to_y

Private Instance Methods

base_structure() click to toggle source
# File lib/latinverb_serialization/hash.rb, line 15
def base_structure
  { 'original_string' => @original_string }
end