Cross Reference: readability.rb
xref
: /
ontohub
/
app
/
models
/
ontology_member
/
symbol
/
readability.rb
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
readability.rb revision 335258a6512a35cb1bb18c1d1693fd35016616bd
# The model Symbol is namespaces in the module OntologyMember because the class
# Symbol is already taken by ruby.
module
OntologyMember
module
Symbol
::
Readability
extend
ActiveSupport
::
Concern
included
do
before_save
:
set_display_name_and_iri
end
def
set_display_name_and_iri
name_iri
=
URI.parse
(
name_is_iri_and_in_text
)
if
name_is_iri_and_in_text
if
name_iri
self.display
_name
=
name_iri.fragment
||
name_iri.path.split
(
"/"
)
.
last
self.iri
=
name_iri.to
_s
self.display_name.gsub
!
(/_/,
' '
)
else
self.display
_name
=
name
end
set_obo_display_name_if_applicable
end
def
name_is_iri_and_in_text
self.text
[
self.name
][
URI
::
regexp
(
Settings.allowed
_iri_schemes
)
]
rescue
StandardError
false
end
def
set_obo_display_name_if_applicable
if
ontology.file
_extension
==
'.obo'
&&
label
self.display
_name
=
label
end
end
end
end