class AsciiBinder::Site

Attributes

id[R]
name[R]
url[R]

Public Class Methods

new(distro_config) click to toggle source
# File lib/ascii_binder/site.rb, line 9
def initialize(distro_config)
  @id   = distro_config['site']
  @name = distro_config['site_name']
  @url  = distro_config['site_url']
end

Public Instance Methods

errors() click to toggle source
# File lib/ascii_binder/site.rb, line 19
def errors
  validate(true)
end
is_valid?() click to toggle source
# File lib/ascii_binder/site.rb, line 15
def is_valid?
  validate
end

Private Instance Methods

validate(verbose=false) click to toggle source
# File lib/ascii_binder/site.rb, line 25
def validate(verbose=false)
  errors = []
  unless valid_id?(@id)
    if verbose
      errors << "Site ID '#{@id}' is not a valid ID."
    else
      return false
    end
  end
  unless valid_string?(@name)
    if verbose
      errors << "Site name '#{@name}' for site ID '#{@id}' is not a valid string."
    else
      return false
    end
  end
  unless valid_string?(@url)
    if verbose
      errors << "Site URL '#{@url}' for site ID '#{@id}' is not a valid string."
    else
      return false
    end
  end
  return errors if verbose
  return true
end