lib/MESH/heading.rb in mesh-medical-subject-headings-2.0.2 vs lib/MESH/heading.rb in mesh-medical-subject-headings-2.0.3
- old
+ new
@@ -18,10 +18,20 @@
def summary(locale = default_locale)
return @summary[locale]
end
+ def linkify_summary
+ linkified_summary = summary.dup
+ linkified_summary.scan(/[A-Z]+[A-Z,\s]+[A-Z]+/).each do |text|
+ heading = @tree.where(entries: /^#{text.strip}$/i).first
+ replacement_text = yield text, heading
+ linkified_summary.sub!(text, replacement_text)
+ end
+ linkified_summary
+ end
+
def entries(locale = default_locale)
@entries[locale] ||= []
return @entries[locale]
end
@@ -71,14 +81,18 @@
end
end
return true
end
- def inspect
+ def to_s
return "#{unique_id}, #{original_heading}, [#{tree_numbers.join(',')}]"
end
+ def inspect
+ to_s
+ end
+
def set_original_heading(heading, locale = default_locale)
@original_heading[locale] = heading
end
def set_natural_language_name(name, locale = default_locale)
@@ -89,10 +103,11 @@
@summary[locale] = summary
end
private
- def initialize
+ def initialize(tree)
+ @tree = tree
@useful = true
@tree_numbers = []
@roots = []
@parents = []
@children = []