`
yang_kunlun
  • 浏览: 74833 次
  • 性别: Icon_minigender_1
  • 来自: 地球
最近访客 更多访客>>
社区版块
存档分类
最新评论

Ruby Formatting

阅读更多
1. Two spaces indentation
2. Comments
New:

# The comment



Old:

#      The comment



3. Whitespace should be used to split up the code, not random
4. Lining up and spacing
4.a spaces between variables and equals
4.b lining up

New:

@task_data    = WorkItem.find_by_sql(str_task)
@project_data = WorkItem.find_by_sql(str_project)



Old:

@task_data=WorkItem.find_by_sql(str_task)
@project_data=WorkItem.find_by_sql(str_project)



5. use #{}
instead of escpaing out

= '" + @day_info.original_id.to_s + "' group



6. Don't commit large blocks of commented code (i.e. daicens version)

7. Case statments use

case
  when "bla"  then something
  when "bla2" then something_else
  else "something"
end



or

case
  when "bla"
    then something
  when "else"
   then something



8. Don't explicitly use "return" unless you need it
i.e.
new:

def bla
  whatever
end


old:
def bla
  return whatever
end



9. format your blocks
instead of


new_object.delete_if{|key,value|(key=='id')||(key=='revision')||(key=='lastModifiedByClient')||(key=='regularTime')||(key=='hasWorkItems')||(key=='hasInvalidWorkItems')||(key=='hasTags')}

分享到:
评论

相关推荐

    Ruby袖珍参考手册

    Whether you've come to Ruby because of the Rails web development framework --Ruby's killer app -- ...sprintf andtime formatting directories Interactive Ruby (irb) and the Ruby debugger Ruby documentation

    Ruby Pocket Reference

    String, Array, and Hash classes and the Kernel module sprintf andtime formatting directories Interactive Ruby (irb) and the Ruby debugger Ruby documentation You also get information ...

    validates_formatting_of:包装在gem中的Common Rails验证

    支持的Ruby版本 1.9.3 2.0.0 2.1.0 2.2.0 安装 要安装validates_formatting_of ,请将以下内容添加到您的Gemfile : gem 'validates_formatting_of' 然后捆绑安装: bundle install 用法 使用validates_...

    text-formatting-lab-v-000

    正在为网页的可见内容完成所有格式和样式设置,添加图像和链接等。... 首先,让我们开始在body标签内键入Hello World 。... 如果您打开一个指向该页面的Web选项卡,则应该在页面上看到文字“ Hello World”。...

    writeexcel:ruby gem用于写入跨平台Excel二进制文件

    writeexcel ...workbook and formatting can be applied to cells. Text, numbers, formulas, hyperlinks, images and charts can be written to the cells. TThe Excel file produced by this module is c

    text-formatting-lab-london-fe-082018

    问题陈述 ... 正在为网页的可见内容完成所有格式和样式,添加图像和链接等工作。... ... 目标 了解最常见的文本格式标签 通过使一些内容出现在网页上来实践我们学到的知识 ... 首先,让我们开始在body标签内键入Hello World 。...

    html-fundamentals-text-formatting-lab-teacher-onboarding

    HTML中的文本格式 学习目标 识别最常见的文本格式标签 ...介绍 ... 正在为网页的可见内容完成所有格式和样式设置,添加图像和链接等。... ... 首先,让我们开始在body标签内输入Hello World 。... 您应该会在页面上看到

    text-formatting-lab-online-web-sp-000

    正在为网页的可见内容完成所有格式和样式设置,添加图像和链接等。... 首先,让我们开始在body标签内键入Hello World 。... 如果您打开一个指向该页面的Web选项卡,则应该在页面上看到文字“ Hello World”。...

    text-formatting-lab-onl01-seng-ft-061520

    正在为网页的可见内容完成所有格式和样式,添加图像和链接等工作。... 首先,让我们开始在body标签内键入Hello World 。... 如果您打开一个指向该网页的标签,您应该会在页面上看到文字“ Hello World”。...

    html-fundamentals-text-formatting-lab-london-web-010620

    HTML中的文本格式学习目标识别最常见的文本格式标签应用HTML概念在网页上显示内容介绍在浏览器中,HTML文档的所有可见内容都包含在body标签内。... 正在为网页的可见内容完成所有格式和样式设置,添加图像和链接等。...

    html-fundamentals-text-formatting-lab-lax-web-100719

    HTML中的文本格式学习目标识别最常见的文本格式标签应用HTML概念以在网页上显示内容介绍在浏览器中,HTML文档的所有可见内容都包含在body标签内。... 正在为网页的可见内容完成所有格式和样式设置,添加图像和链接等。...

    html-fundamentals-text-formatting-lab-lax-web-033020

    HTML中的文本格式学习目标识别最常见的文本格式标签应用HTML概念以在网页上显示内容介绍在浏览器中,HTML文档的所有可见内容都包含在body标签内。... 正在为网页的可见内容完成所有格式和样式设置,添加图像和链接等。...

    html-fundamentals-text-formatting-lab-wdc01-seng-ft-111620

    HTML中的文本格式 学习目标 识别最常见的文本格式标签 ...介绍 ... 正在为网页的可见内容完成所有格式和样式设置,添加图像和链接等。... ... 首先,让我们开始在body标签内输入Hello World 。... 您应该会在页面上看到

    Packt.Publishing.CakePHP.Application.Development.Jun.2008

    Another minor gripe I have with the book is the incredibly inconsistent formatting of the code examples. Indents were all over the place, as were line wraps, making it very difficult to follow. I ...

    vscode-sass-format:Visual Studio Code的Sass格式化程序扩展

    您可以继续在旧的Sass(Ruby Sass)实现中使用此扩展。要求需要安装命令行工具。 经过测试的sass命令行工具: 。 重要的是,此扩展不支持年推出的 因为Dart实施中未提供sass-convert功能(更多详细信息: )。 此...

    redmine_wiki_notes:向 wiki 添加一些宏以显示 noteinfowarningtip 块

    {{note(text with *wiki formatting*)}} {{note Alternately, you can put blocks of *wiki-formatted* text here. }} {{note(Or if you really want) You can do both... }} 这将在 wiki 页面中显示一个带有相应...

    chef-provisioning-test-suite:你喜欢厨师金属。 我喜欢厨师金属。 我测试你的厨师金属

    # rspec goodies: cleanup, log capture, formatting rspec spec -t driver_family:cloud # run all cloud driver tests “嘿!这看起来就像厨师金属一样!” 而且,你是对的。 “那么,什么给?” 好吧,我们正在...

    lint-action::sparkles:用于检测和修复lint错误的GitHub动作

    Ruby: Swift: (官方) (作者Nick Lockwood) 用法 在您的项目中创建一个新的GitHub Actions工作流,例如在.github/workflows/lint.yml 。 文件内容应采用以下格式: name : Lint on : push jobs : run-...

    intl-tel-input-rails:用于Rails资产管道的intl-tel-input

    国际电话输入导轨这个gem是库的简单包装。安装将此行添加到您的应用程序的Gemfile中: gem 'intl-tel-input-rails'然后执行: $ bundle或自己安装为: $ gem install intl-tel-input-rails用法将以下指令添加到您的...

Global site tag (gtag.js) - Google Analytics