• sample

    By Niklas Heidloff 1 decade ago

    Great project. Thanks a lot for contributing !

     

    I have your date sample running. However I'm not that familiar with Ruby. Could you pls provide a more sophisticated sample that I could use in the mini video that I want to produce? A sample showing how to use the objects like database and the # and $ notations would be great and maybe some Ruby specific features like each.

    • Hmm,good idea

      By Jesse Gallagher 1 decade ago

      Looking through my blog DB, most of the Ruby code is pretty small and single-purpose (I blame XPages for requiring very little non-declarative code in a lot of cases). I should probably come up with an overall "Why Would I Do This?" document explaining how Ruby differs from Java, JavaScript, and LotusScript, with some larger examples of Domino-specific code.

      I'll see what I can do about a proper example. In the mean time, this snippet, which pulls in the archive's months from a view and converts them to Java dates, at least uses the #collect method, which is like @Transform(), as well as JRuby's translation of camelCase to underscore_separated names to match the overall Ruby style:

       

      <xp:dataContext var="archiveMonths">
      
          <xp:this.value><![CDATA[${ruby:
      
              posts = database.get_view("Posts by Month")
      
              months = posts.get_column_values(0)
      
              posts.recycle
      
              months.collect { |dateTime| d = dateTime.to_java_date; dateTime.recycle; d }
      
          }]]></xp:this.value>
      
      </xp:dataContext>