Class: Milkode::Package
- Inherits:
-
Object
- Object
- Milkode::Package
- Defined in:
- lib/milkode/cdstk/package.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#==(rhs) ⇒ Object
同値検査.
- #directory ⇒ Object
- #fav? ⇒ Boolean
- #hash ⇒ Object
- #ignore ⇒ Object
-
#initialize(hash) ⇒ Package
constructor
A new instance of Package.
- #migrate ⇒ Object
- #name ⇒ Object
- #options ⇒ Object
-
#same_name?(a_name) ⇒ Boolean
同名パッケージか?.
- #set_fav(value) ⇒ Object
- #set_ignore(ignore) ⇒ Object
- #set_options(options) ⇒ Object
Constructor Details
#initialize(hash) ⇒ Package
Returns a new instance of Package.
20 21 22 23 |
# File 'lib/milkode/cdstk/package.rb', line 20 def initialize(hash) @hash = hash normalize end |
Class Method Details
Instance Method Details
#==(rhs) ⇒ Object
同値検査
68 69 70 |
# File 'lib/milkode/cdstk/package.rb', line 68 def ==(rhs) name == rhs.name && directory == rhs.directory && ignore == rhs.ignore end |
#directory ⇒ Object
33 34 35 |
# File 'lib/milkode/cdstk/package.rb', line 33 def directory @hash['directory'] end |
#fav? ⇒ Boolean
72 73 74 |
# File 'lib/milkode/cdstk/package.rb', line 72 def fav? [:fav] == true end |
#hash ⇒ Object
53 54 55 |
# File 'lib/milkode/cdstk/package.rb', line 53 def hash @hash end |
#ignore ⇒ Object
37 38 39 |
# File 'lib/milkode/cdstk/package.rb', line 37 def ignore @hash['ignore'] || [] end |
#migrate ⇒ Object
57 58 59 60 |
# File 'lib/milkode/cdstk/package.rb', line 57 def migrate # 色々あって、ignore値はデフォルトで設定しないようにした # @hash['ignore'] = [] unless ignore end |
#name ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/milkode/cdstk/package.rb', line 25 def name if [:name] [:name] else File.basename(directory) end end |
#options ⇒ Object
45 46 47 |
# File 'lib/milkode/cdstk/package.rb', line 45 def @hash['options'] || {} end |
#same_name?(a_name) ⇒ Boolean
同名パッケージか?
63 64 65 |
# File 'lib/milkode/cdstk/package.rb', line 63 def same_name?(a_name) name == a_name end |
#set_fav(value) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/milkode/cdstk/package.rb', line 76 def set_fav(value) if value if @hash['options'] @hash['options'][:fav] = true else @hash['options'] = {:fav => true} end else @hash['options'].delete(:fav) if @hash['options'] end end |
#set_ignore(ignore) ⇒ Object
41 42 43 |
# File 'lib/milkode/cdstk/package.rb', line 41 def set_ignore(ignore) @hash['ignore'] = ignore end |
#set_options(options) ⇒ Object
49 50 51 |
# File 'lib/milkode/cdstk/package.rb', line 49 def () @hash['options'] = end |