Class: Standupguy::Item::TicketUrl

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

Constant Summary collapse

CLASSIC_TICKET =
%r{https?:\/\/(.*?)\.zendesk.com\/[a-z].*?\/(.*)}
LOTUS_TICKET =
%r{https?:\/\/(.*?)\.zendesk.com\/agent\/#?\/?tickets\/(\d+)\/?.*?}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ TicketUrl



241
242
243
244
245
246
247
# File 'lib/Standupguy.rb', line 241

def initialize(url)
  [LOTUS_TICKET, CLASSIC_TICKET].each do |pattern|
    subdomain, id = url.downcase.scan(pattern).flatten
    super(url, subdomain, id)
    return if self.valid?
  end
end

Instance Attribute Details

#idObject

Returns the value of attribute id



237
238
239
# File 'lib/Standupguy.rb', line 237

def id
  @id
end

#subdomainObject

Returns the value of attribute subdomain



237
238
239
# File 'lib/Standupguy.rb', line 237

def subdomain
  @subdomain
end

#urlObject

Returns the value of attribute url



237
238
239
# File 'lib/Standupguy.rb', line 237

def url
  @url
end

Instance Method Details

#valid?Boolean



249
250
251
# File 'lib/Standupguy.rb', line 249

def valid?
  !(id.nil? && subdomain.nil?)
end