Class: Inform::Ephemeral::Module

Inherits:
Object
  • Object
show all
Defined in:
lib/story_teller/inform/ephemeral/module.rb

Overview

class Module

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.dirtyObject

rubocop: disable Style/FormatString rubocop: disable Style/FormatStringToken



48
49
50
51
52
53
54
55
# File 'lib/story_teller/inform/ephemeral/module.rb', line 48

def self.dirty
  results = db.fetch %{select a.id, a.name from module a group by a.id, a.name having
((select count(b.id) from modularized b where b.module_id = a.id) = 0)}
  return nil if results.empty?
  s = ["%5s %20s" % results.first.keys]
  s.concat(results.collect { |row| "%5d %20s" % row.values })
  s.join("\n")
end

.statsObject

rubocop: disable Style/FormatString rubocop: disable Style/FormatStringToken



61
62
63
64
65
66
67
68
# File 'lib/story_teller/inform/ephemeral/module.rb', line 61

def self.stats
  results = db.fetch %{select a.*, count(a.id) as "number modularized"
from module a, modularized b where b.module_id = a.id group by a.id, a.name}
  return nil if results.empty?
  s = ["%5s %20s %15s" % results.first.keys]
  s.concat(results.collect { |row| "%5d %20s %15s" % row.values })
  s.join("\n")
end

.tidyObject



38
39
40
41
42
43
44
# File 'lib/story_teller/inform/ephemeral/module.rb', line 38

def self.tidy
  db << %{delete from module where id in
(select a.id from module a group by a.id, a.name
having ((select count(b.id) from modularized b
where b.module_id = a.id) = 0))}
  return nil
end

Instance Method Details

#<=>(other) ⇒ Object



34
35
36
# File 'lib/story_teller/inform/ephemeral/module.rb', line 34

def <=>(other)
  self.name <=> other.name
end

#to_sObject



30
31
32
# File 'lib/story_teller/inform/ephemeral/module.rb', line 30

def to_s
  name
end