Class: GenericSite

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

Overview

++

Constant Summary collapse

MAX_ERRORS =
3
SENDLIST =
'sendeliste.dat'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ GenericSite

Returns a new instance of GenericSite.



33
34
35
36
37
38
39
40
# File 'lib/multistockphoto/generic_site.rb', line 33

def initialize(name)
  @name = name
  @max_errors = MAX_ERRORS
  unless File.exist?(SENDLIST)
    warn "File #{SENDLIST} does not exist - creating empty file"
    File.open(SENDLIST,"w"){|file|}
  end
end

Instance Attribute Details

#max_errorsObject

Returns the value of attribute max_errors.



28
29
30
# File 'lib/multistockphoto/generic_site.rb', line 28

def max_errors
  @max_errors
end

#nameObject (readonly)

Returns the value of attribute name.



27
28
29
# File 'lib/multistockphoto/generic_site.rb', line 27

def name
  @name
end

#passwordObject

Returns the value of attribute password.



28
29
30
# File 'lib/multistockphoto/generic_site.rb', line 28

def password
  @password
end

#userObject

Returns the value of attribute user.



28
29
30
# File 'lib/multistockphoto/generic_site.rb', line 28

def user
  @user
end

Instance Method Details

#already_sent_site?(photo, site) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
54
55
56
57
58
59
60
# File 'lib/multistockphoto/generic_site.rb', line 51

def already_sent_site?(photo,site)
  unless photo.class == Photo
    raise 'not a Photo object'
  end
  unless File.exist?(photo.filename)
    raise "file #{photo.filename} does not exist"
  end
  g = grep(SENDLIST, /#{site}\t#{photo.filename}/)
  return g.size > 0
end

#heute_schon_gesendet(site) ⇒ Object



47
48
49
# File 'lib/multistockphoto/generic_site.rb', line 47

def heute_schon_gesendet(site)
  sent_today_site(site)
end

#photos_fuer_heute_uebrig?Boolean

Returns:

  • (Boolean)


42
43
44
45
# File 'lib/multistockphoto/generic_site.rb', line 42

def photos_fuer_heute_uebrig?
  # puts "noch #{total_per_day - sent_today} zu senden"
  return total_per_day - sent_today > 0
end

#photosize_valid?(photo) ⇒ Boolean

Groesse der Datei gueltig fuer die Site, auch in Verbindung mit File-Typ

Returns:

  • (Boolean)


63
64
65
# File 'lib/multistockphoto/generic_site.rb', line 63

def photosize_valid?(photo)
  true
end