Return primary form
This commit is contained in:
parent
e0a9a2624b
commit
77e3d97a19
1 changed files with 16 additions and 0 deletions
16
main.rb
16
main.rb
|
@ -26,6 +26,7 @@ get '/words/:id' do
|
|||
word_id = Integer params[:id]
|
||||
|
||||
json({
|
||||
primary_form: context.primary_form(word_id),
|
||||
part_of_speech: context.part_of_speech_name(word_id),
|
||||
examples: context.examples(word_id),
|
||||
})
|
||||
|
@ -67,6 +68,21 @@ private
|
|||
|
||||
public
|
||||
|
||||
##
|
||||
# @return [String, nil]
|
||||
#
|
||||
def primary_form(word_id)
|
||||
word_id = Integer word_id
|
||||
|
||||
column = @db_conn.exec_params(
|
||||
'SELECT primary_form FROM words WHERE id = $1',
|
||||
[word_id],
|
||||
).values.first&.first
|
||||
|
||||
str = String(column).strip.freeze
|
||||
str unless str.empty?
|
||||
end
|
||||
|
||||
##
|
||||
# @return [String, nil]
|
||||
#
|
||||
|
|
Loading…
Reference in a new issue