Class: String

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

Instance Method Summary collapse

Instance Method Details

#domainObject

returns all of the url before and including the domain ending



81
82
83
84
85
86
87
88
89
90
# File 'lib/random_methods.rb', line 81

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 + 2
    domainName = self[0..domainEnd]
    return domainName
  end
end

#halfObject



50
51
52
53
54
55
# File 'lib/random_methods.rb', line 50

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

#index_domainObject

made for link class



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

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



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

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

#three_quartersObject



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

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