Class: TimexDatalinkClient::Protocol7::PhraseBuilder
- Inherits:
-
Object
- Object
- TimexDatalinkClient::Protocol7::PhraseBuilder
- Defined in:
- lib/timex_datalink_client/protocol_7/phrase_builder.rb
Defined Under Namespace
Classes: WordNotFound
Instance Attribute Summary collapse
-
#database ⇒ Object
Returns the value of attribute database.
Instance Method Summary collapse
-
#initialize(database:) ⇒ PhraseBuilder
constructor
Create a PhraseBuilder instance.
-
#vocab_ids_for(*words) ⇒ Array<Integer>
Compile vocabulary IDs for protocol 7 phrases.
Constructor Details
#initialize(database:) ⇒ PhraseBuilder
Create a PhraseBuilder instance.
16 17 18 |
# File 'lib/timex_datalink_client/protocol_7/phrase_builder.rb', line 16 def initialize(database:) @database = database end |
Instance Attribute Details
#database ⇒ Object
Returns the value of attribute database.
10 11 12 |
# File 'lib/timex_datalink_client/protocol_7/phrase_builder.rb', line 10 def database @database end |
Instance Method Details
#vocab_ids_for(*words) ⇒ Array<Integer>
Compile vocabulary IDs for protocol 7 phrases.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/timex_datalink_client/protocol_7/phrase_builder.rb', line 25 def vocab_ids_for(*words) words.flat_map do |word| vocab = vocab_for_word(word) raise(WordNotFound, "#{word} is not a valid word!") unless vocab vocab_links = vocab_links_for_vocab(vocab) vocab_links.map do |vocab_link| linked_vocab = vocab_for_vocab_link(vocab_link) linked_vocab[:"PC Index"].to_i end end end |