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)


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

Returns:

  • (Boolean)


71
72
73
# File 'lib/overwrite.rb', line 71

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)


67
68
69
# File 'lib/overwrite.rb', line 67

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



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

Returns:

  • (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