Skip to content

Commit

Permalink
fix LocalizedString#to_s
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew2net committed Sep 22, 2021
1 parent 9106c9c commit a4fa476
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions lib/relaton_bib/localized_string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ def initialize(content, language = nil, script = nil) # rubocop:disable Metrics/
if content.is_a?(Array) && content.none?
raise ArgumentError, "LocalizedString content is empty"
end

@language = language.is_a?(String) ? [language] : language
@script = script.is_a?(String) ? [script] : script
@content = if content.is_a?(Array)
content.map do |c|
if c.is_a?(Hash)
case c
when Hash
LocalizedString.new c[:content], c[:language], c[:script]
elsif c.is_a?(String)
LocalizedString.new c
when String then LocalizedString.new c
else c
end
end
Expand All @@ -38,7 +39,7 @@ def initialize(content, language = nil, script = nil) # rubocop:disable Metrics/

# @return [String]
def to_s
content.is_a?(String) ? content : content.first.to_s
content.is_a?(Array) ? content.first.to_s : content.to_s
end

# @return [TrueClass, FalseClass]
Expand Down
2 changes: 1 addition & 1 deletion lib/relaton_bib/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module RelatonBib
VERSION = "1.9.1".freeze
VERSION = "1.9.2".freeze
end

0 comments on commit a4fa476

Please sign in to comment.