Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/parser.rb,
lib/to-html.rb,
lib/overwrite.rb

Direct Known Subclasses

OpenTox::WrapperResult

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.model_uri?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/overwrite.rb', line 69

def self.model_uri?
 self.uri? && !self.match(/model/).nil?
end

Instance Method Details

#dataset_uri?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/overwrite.rb', line 65

def dataset_uri?
 self.uri? && !self.match(/dataset/).nil?
end

encloses URI in text with with link tag

Returns:

  • (String)

    new text with marked links



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

Returns:

  • (Boolean)


61
62
63
# File 'lib/overwrite.rb', line 61

def task_uri?
  self.uri? && !self.match(/task/).nil?
end

#to_tripleArray

Split RDF statement into triples

Returns:

  • (Array)

    Array with [subject,predicate,object]



8
9
10
# File 'lib/parser.rb', line 8

def to_triple
  self.chomp.split(' ',3).collect{|i| i.sub(/\s+.$/,'').gsub(/[<>"]/,'')}
end

#underscoreObject



82
83
84
85
86
87
88
# File 'lib/overwrite.rb', line 82

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

Returns:

  • (Boolean)


73
74
75
76
77
78
79
80
# File 'lib/overwrite.rb', line 73

def uri?
  begin
    u = URI::parse(self)
    return (u.scheme!=nil and u.host!=nil)
  rescue URI::InvalidURIError
    return false
  end
end