Class: DocStat::Container
- Inherits:
-
Object
- Object
- DocStat::Container
- Defined in:
- lib/docstat/container.rb
Constant Summary collapse
- QUERY =
"select ZCONTAINERNAME,ZTOKENNAME,ZTYPENAME,ZTOKENMETAINFORMATION.ZABSTRACT,ZDECLARATION,ZRETURNVALUE.ZABSTRACT from ZTOKEN \ inner join ZCONTAINER on ZTOKEN.ZCONTAINER = ZCONTAINER.Z_PK \ inner join ZTOKENTYPE on ZTOKEN.ZTOKENTYPE = ZTOKENTYPE.Z_PK \ inner join ZTOKENMETAINFORMATION on ZTOKEN.Z_PK = ZTOKENMETAINFORMATION.ZTOKEN \ left join ZRETURNVALUE on (ZTOKENMETAINFORMATION.ZRETURNVALUE = ZRETURNVALUE.Z_PK) \ order by ZCONTAINERNAME"
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
Class Method Summary collapse
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(name, tokens) ⇒ Container
constructor
A new instance of Container.
- #method_documentation_ratio ⇒ Object
- #property_documentation_ratio ⇒ Object
- #ratio ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(name, tokens) ⇒ Container
Returns a new instance of Container.
27 28 29 |
# File 'lib/docstat/container.rb', line 27 def initialize name, tokens @name, @tokens = name, tokens.map {|t| Token.new(t)} end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/docstat/container.rb', line 7 def name @name end |
#tokens ⇒ Object (readonly)
Returns the value of attribute tokens.
7 8 9 |
# File 'lib/docstat/container.rb', line 7 def tokens @tokens end |
Class Method Details
.from_sqlite(path) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/docstat/container.rb', line 16 def self.from_sqlite path db = SQLite3::Database.new(path) rows = db.execute(QUERY).to_a container_groups = rows.group_by {|r| r.first } groups = container_groups.map do |name, tokens| self.new(name, tokens) end db.close groups end |
Instance Method Details
#description ⇒ Object
51 52 53 54 |
# File 'lib/docstat/container.rb', line 51 def description token_description = tokens.map {|t| t.description}.join("\n") "#{name}:\n#{token_description}" end |
#method_documentation_ratio ⇒ Object
43 44 45 |
# File 'lib/docstat/container.rb', line 43 def method_documentation_ratio documentation_ratio(tokens.select(:method?)) end |
#property_documentation_ratio ⇒ Object
47 48 49 |
# File 'lib/docstat/container.rb', line 47 def property_documentation_ratio documentation_ratio(tokens.select(:property?)) end |
#ratio ⇒ Object
39 40 41 |
# File 'lib/docstat/container.rb', line 39 def ratio documentation_ratio(tokens) end |
#to_hash ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/docstat/container.rb', line 31 def to_hash { "name" => name, "tokens" => tokens.map(&:to_hash), "ratio" => ratio } end |