Class: Moura::View::Diff
- Inherits:
-
Object
- Object
- Moura::View::Diff
- Defined in:
- lib/moura/view/diff.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(diff) ⇒ Diff
constructor
A new instance of Diff.
- #show ⇒ Object
- #show_child(data, name) ⇒ Object
- #symbol_to_mark(sym) ⇒ Object
Constructor Details
#initialize(diff) ⇒ Diff
Returns a new instance of Diff.
8 9 10 |
# File 'lib/moura/view/diff.rb', line 8 def initialize(diff) @data = diff end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/moura/view/diff.rb', line 6 def data @data end |
Instance Method Details
#show ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/moura/view/diff.rb', line 12 def show @data.each do |role, attr| mark = symbol_to_mark(attr[:action]) puts "#{mark} #{role}" show_child(attr[:apps], "アプリケーション") show_child(attr[:users], "ユーザ") end end |
#show_child(data, name) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/moura/view/diff.rb', line 29 def show_child(data, name) return if data[:add].empty? && data[:remove].empty? puts " => #{name}" data[:add].sort.each do |a| puts "+ #{a}" end data[:remove].sort.each do |r| puts "- #{r}" end end |
#symbol_to_mark(sym) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/moura/view/diff.rb', line 21 def symbol_to_mark(sym) case sym when :add then "+" when :remove then "-" else " " end end |