Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/parser.rb,
lib/to-html.rb,
lib/overwrite.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #dataset_uri? ⇒ Boolean
-
#link_urls ⇒ String
encloses URI in text with with link tag.
- #task_uri? ⇒ Boolean
-
#to_triple ⇒ Array
Split RDF statement into triples.
- #underscore ⇒ Object
- #uri? ⇒ Boolean
Class Method Details
.model_uri? ⇒ Boolean
75 76 77 |
# File 'lib/overwrite.rb', line 75 def self.model_uri? self.uri? && !self.match(/model/).nil? end |
Instance Method Details
#dataset_uri? ⇒ Boolean
71 72 73 |
# File 'lib/overwrite.rb', line 71 def dataset_uri? self.uri? && !self.match(/dataset/).nil? end |
#link_urls ⇒ String
encloses URI in text with with link tag
8 9 10 |
# File 'lib/to-html.rb', line 8 def link_urls self.gsub(/(?i)http(s?):\/\/[^\r\n\s']*/, '<a href="\0">\0</a>') end |
#task_uri? ⇒ Boolean
67 68 69 |
# File 'lib/overwrite.rb', line 67 def task_uri? self.uri? && !self.match(/task/).nil? end |
#to_triple ⇒ Array
Split RDF statement into triples
8 9 10 |
# File 'lib/parser.rb', line 8 def to_triple self.chomp.split(' ',3).collect{|i| i.sub(/\s+.$/,'').gsub(/[<>"]/,'')} end |
#underscore ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/overwrite.rb', line 88 def underscore self.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end |
#uri? ⇒ Boolean
79 80 81 82 83 84 85 86 |
# File 'lib/overwrite.rb', line 79 def uri? begin u = URI::parse(self) return (u.scheme!=nil and u.host!=nil) rescue URI::InvalidURIError return false end end |