Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/random_methods.rb

Constant Summary collapse

@@Domains =
Regexp.union(domainEnd)

Instance Method Summary collapse

Instance Method Details

#domainObject

returns all of the url before and including the domain ending



96
97
98
99
100
101
102
103
104
105
# File 'lib/random_methods.rb', line 96

def domain # returns all of the url before and including the domain ending
  domainIndex = self.index(@@Domains)
  if domainIndex == nil then
    return nil
  else
    domainEnd = domainIndex + 3
    domainName = self[0..domainEnd]
    return domainName
  end
end

#halfObject



58
59
60
61
62
63
# File 'lib/random_methods.rb', line 58

def half
  strL = self.length
  strH = strL / 2
  newString = self[0..strH]
  return newString
end

#index_domainObject

made for link class



87
88
89
90
91
92
93
94
# File 'lib/random_methods.rb', line 87

def index_domain # gives index of the domain ending
  domainIndex = self.index(@@Domains)
  if domainIndex == nil then
    return nil
  else
    return domainIndex
  end
end

#quarterObject



65
66
67
68
69
70
# File 'lib/random_methods.rb', line 65

def quarter
  strL = self.length
  strH = strL / 4
  newString = self[0..strH]
  return newString
end

#test_for(item) ⇒ Object



79
80
81
82
83
84
85
# File 'lib/random_methods.rb', line 79

def test_for(item)
  if self[item] then
    return true
  else
    return false
  end
end

#three_quartersObject



72
73
74
75
76
77
# File 'lib/random_methods.rb', line 72

def three_quarters
  strL = self.length
  strH = strL - (strL / 4)
  newString = self[0..strH]
  return newString
end